Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
construct_output_selector,
construct_step_selector,
get_last_chunk_of_selector,
get_input_selector_base,
get_nodes_of_specific_category,
get_step_selector_from_its_output,
identify_lineage,
Expand Down Expand Up @@ -282,7 +283,7 @@ def add_edge_for_step(
if is_input_selector(target_step_parsed_selector.value):
input_node_compilation_data = node_as(
execution_graph=execution_graph,
node=target_step_parsed_selector.value,
node=get_input_selector_base(target_step_parsed_selector.value),
expected_type=InputNode,
)
actual_input_kind = input_node_compilation_data.input_manifest.kind
Expand Down
10 changes: 10 additions & 0 deletions inference/core/workflows/execution_engine/v1/compiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def get_last_chunk_of_selector(selector: str) -> str:
return selector.split(".")[-1]


def get_input_selector_base(selector: str) -> str:
"""Strip sub-property suffix from input selector.
e.g. $inputs.image.name -> $inputs.image
"""
parts = selector.split(".")
if len(parts) > 2:
return ".".join(parts[:2])
return selector


def is_control_flow_step(execution_graph: DiGraph, node: str) -> bool:
if not is_step_node(execution_graph=execution_graph, node=node):
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,15 @@ def test_is_selector_when_not_a_selector_given(value: Any) -> None:

# then
assert result is False


def test_get_input_selector_base_with_sub_property():
# $inputs.image.name should be stripped to $inputs.image
from inference.core.workflows.execution_engine.v1.compiler.utils import get_input_selector_base
assert get_input_selector_base("$inputs.image.name") == "$inputs.image"


def test_get_input_selector_base_without_sub_property():
# $inputs.image should remain unchanged
from inference.core.workflows.execution_engine.v1.compiler.utils import get_input_selector_base
assert get_input_selector_base("$inputs.image") == "$inputs.image"