-
Notifications
You must be signed in to change notification settings - Fork 229
Adds support for selectors in Union[List[...], Selector(...)] patterns #1764
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
base: main
Are you sure you want to change the base?
Conversation
…ctor(...)] patterns. Added checks for array and dict types in schema parser, and updated selectors parser to handle runtime type checks. Included regression tests to ensure correct behavior for mixed lists and selector definitions.
| contains_array_type = False | ||
| contains_dict_type = False | ||
| for type_definition in union_types: | ||
| if type_definition.get("type") == "array" and ITEMS_KEY in type_definition: |
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.
please use constants for key names
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.
and also values
PawelPeczek-Roboflow
left a comment
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.
I may not understand something or the tests are simply written to illustrate wrong use-case - almost like it attempts to seek for nested selectors when the type annotation is Union[List[str], Selector(kind=[LIST_OF_VALUES]), when the initial problem was nesting when type is Union[List[Union[str, Selector(kind=[STRING])]], Selector(kind=[LIST_OF_VALUES])
if the code works as if the Union[List[Union[str, Selector(kind=[STRING])]], Selector(kind=[LIST_OF_VALUES]) is provided in situation when Union[List[str], Selector(kind=[LIST_OF_VALUES]) then this is introducing bug
| contains_array_type = False | ||
| contains_dict_type = False | ||
| for type_definition in union_types: | ||
| if type_definition.get("type") == "array" and ITEMS_KEY in type_definition: |
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.
and also values
Description
Fixes selector extraction in workflow blocks with
Union[List[T], Selector(...)]properties. Previously, selectors in mixed lists like["literal", "$inputs.tag"]were not parsed correctly, causing them to be treated as literal strings instead of being resolved at runtime.The fix updates the schema parser to detect array types in union variants and set
is_list_element=Trueappropriately, then modifies the selector parser to use runtime type checking. This enables proper selector resolution in blocks likeDetectionsConsensus.classes_to_considerandBoundingBoxVisualization.custom_colors. Includes unit and integration tests.Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Any specific deployment considerations
For example, documentation changes, usability, usage/costs, secrets, etc.
Docs