-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add is_array filter and test for AttributeType #540
base: main
Are you sure you want to change the base?
Add is_array filter and test for AttributeType #540
Conversation
@arthurDiff Thank you for this PR, but I believe this ticket unfortunately lacked detail. What @lmolkova originally wanted was a Jinja filter or test integrated into our template engine based on the Minijinja implementation. The idea would be to replace this Jinja hack (see the original pb description here): {%- if "[]" in attribute.type and "template" not in attribute.type %}
... with a Jinja test similar to this declaration: {%- if attribute is array %}
... You can find several examples of such tests in the following file (the one you could update): crates/weaver_forge/src/extensions/otel.rs I would be happy to provide more details or any kind of help if needed. |
Hi @lquerel ! Sorry about the delay and thanks for the clarification! Should be implemented with minijinja now. |
matches!( | ||
attr_type, | ||
"string[]" | ||
| "int[]" | ||
| "double[]" | ||
| "boolean[]" | ||
| "template[string[]]" | ||
| "template[int[]]" | ||
| "template[double[]]" | ||
| "template[boolean[]]" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmolkova This test looks fine to me, but could you confirm: for semconvs
, should a template[xxx[]]
be considered an array, or should we treat any template as not being an array, even when templating an array of something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added in documentation update and new test case for full coverage! just let me know if that needs updating!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Just 2 comments:
- I asked Liudmila to confirm if templates of arrays must be considered arrays. Nothing to do on your side for now.
- You should add a description of the Jinja test in the following documentation.
After we should be ready to go :-).
Thank you
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #540 +/- ##
=====================================
Coverage 74.5% 74.5%
=====================================
Files 51 51
Lines 3960 3965 +5
=====================================
+ Hits 2953 2957 +4
- Misses 1007 1008 +1 ☔ View full report in Codecov by Sentry. |
Sounds good! Out of curiosity. is there reason for match attribute types; weaver uses literal string instead of static const?
|
@arthurDiff Regarding your question about strings, I’m not sure I fully understand. Are you suggesting introducing constants instead of using literal strings directly in the code? If so, then yes, they could indeed be replaced with Additionally, I didn’t understand why you closed this PR after making changes. It’s probably an error, so I'm reopening it so that we can proceed with the merge once we have received a response from @lmolkova. Thanks |
Yup! I think using |
Added
is_array
fn to AttributeType enum.