Skip to content

Commit 17073b2

Browse files
committed
fix: resolve input image sub-property selector in workflow compiler (#2113)
When a workflow block references .image.name, the compiler failed to find the node in the execution graph because it passed the full selector string instead of the base input selector. Added get_input_selector_base() helper to strip sub-property suffix from input selectors before graph node lookup.
1 parent a3baebd commit 17073b2

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
construct_output_selector,
7575
construct_step_selector,
7676
get_last_chunk_of_selector,
77+
get_input_selector_base,
7778
get_nodes_of_specific_category,
7879
get_step_selector_from_its_output,
7980
identify_lineage,
@@ -282,7 +283,7 @@ def add_edge_for_step(
282283
if is_input_selector(target_step_parsed_selector.value):
283284
input_node_compilation_data = node_as(
284285
execution_graph=execution_graph,
285-
node=target_step_parsed_selector.value,
286+
node=get_input_selector_base(target_step_parsed_selector.value),
286287
expected_type=InputNode,
287288
)
288289
actual_input_kind = input_node_compilation_data.input_manifest.kind

inference/core/workflows/execution_engine/v1/compiler/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ def get_last_chunk_of_selector(selector: str) -> str:
8585
return selector.split(".")[-1]
8686

8787

88+
def get_input_selector_base(selector: str) -> str:
89+
"""Strip sub-property suffix from input selector.
90+
e.g. $inputs.image.name -> $inputs.image
91+
"""
92+
parts = selector.split(".")
93+
if len(parts) > 2:
94+
return ".".join(parts[:2])
95+
return selector
96+
97+
8898
def is_control_flow_step(execution_graph: DiGraph, node: str) -> bool:
8999
if not is_step_node(execution_graph=execution_graph, node=node):
90100
return False

tests/workflows/unit_tests/execution_engine/compiler/test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,15 @@ def test_is_selector_when_not_a_selector_given(value: Any) -> None:
364364

365365
# then
366366
assert result is False
367+
368+
369+
def test_get_input_selector_base_with_sub_property():
370+
# $inputs.image.name should be stripped to $inputs.image
371+
from inference.core.workflows.execution_engine.v1.compiler.utils import get_input_selector_base
372+
assert get_input_selector_base("$inputs.image.name") == "$inputs.image"
373+
374+
375+
def test_get_input_selector_base_without_sub_property():
376+
# $inputs.image should remain unchanged
377+
from inference.core.workflows.execution_engine.v1.compiler.utils import get_input_selector_base
378+
assert get_input_selector_base("$inputs.image") == "$inputs.image"

0 commit comments

Comments
 (0)