Skip to content

Conversation

@joaomarcoscrs
Copy link
Contributor

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=True appropriately, then modifies the selector parser to use runtime type checking. This enables proper selector resolution in blocks like DetectionsConsensus.classes_to_consider and BoundingBoxVisualization.custom_colors. Includes unit and integration tests.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

  • ✅ New unit tests for Union[List, Selector] patterns
  • ✅ Integration tests with real workflow blocks

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:

…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:
Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also values

Copy link
Collaborator

@PawelPeczek-Roboflow PawelPeczek-Roboflow left a 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants