Skip to content

[ML][Pipelines] Validate invalid scenario: control flow node as init/finalize #26918

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

Merged
merged 6 commits into from
Oct 21, 2022
Merged
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 @@ -331,8 +331,8 @@ def _validate_init_finalize_job(self) -> MutableValidationResult:
validation_result.append_error(yaml_path="jobs", message="No other job except for on_init/on_finalize job.")

def _is_isolated_job(_validate_job_name: str) -> bool:
# no input to validate job
_validate_job = self.jobs[_validate_job_name]
# no input to validate job
for _input_name in _validate_job.inputs:
if not hasattr(_validate_job.inputs[_input_name]._data, "_data_binding"):
continue
Expand All @@ -349,19 +349,29 @@ def _is_isolated_job(_validate_job_name: str) -> bool:
return False
return True

def _is_control_flow_node(_validate_job_name: str) -> bool:
from azure.ai.ml.entities._builders.control_flow_node import ControlFlowNode

_validate_job = self.jobs[_validate_job_name]
return issubclass(type(_validate_job), ControlFlowNode)

# validate on_init
if on_init is not None:
if on_init not in self.jobs:
append_on_init_error(f"On_init job name {on_init} not exists in jobs.")
else:
if not _is_isolated_job(on_init):
if _is_control_flow_node(on_init):
append_on_init_error("On_init job should not be a control flow node.")
elif not _is_isolated_job(on_init):
append_on_init_error("On_init job should not have connection to other execution node.")
# validate on_finalize
if on_finalize is not None:
if on_finalize not in self.jobs:
append_on_finalize_error(f"On_finalize job name {on_finalize} not exists in jobs.")
else:
if not _is_isolated_job(on_finalize):
if _is_control_flow_node(on_finalize):
append_on_finalize_error("On_finalize job should not be a control flow node.")
elif not _is_isolated_job(on_finalize):
append_on_finalize_error("On_finalize job should not have connection to other execution node.")
return validation_result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def subgraph_with_init_func():
subgraph_with_init_func()
assert str(e.value) == "On_init/on_finalize is not supported for pipeline component."

def test_init_finalize_job_with_subgraph(self, caplog) -> None:
def test_init_finalize_job_with_subgraph(self) -> None:
from azure.ai.ml._internal.dsl import set_pipeline_settings

# happy path
Expand Down