-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Support e2e run for if_else node in pipeline #26780
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
acd3444
add e2e test
D-W- 8ebeb40
update test
D-W- 3f5cdf9
fix test
D-W- 44c713a
fix pipeline tests
D-W- b2f449d
Merge branch 'main' into wanhan/e2e_test_for_if_else
D-W- 84f8c8c
add comment
D-W- 1f22181
fix test
D-W- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_dynamic_pipeline.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| import contextlib | ||
| import pytest | ||
|
|
||
| from azure.ai.ml._schema.pipeline import PipelineJobSchema | ||
| from .._util import _DSL_TIMEOUT_SECOND | ||
| from test_utilities.utils import _PYTEST_TIMEOUT_METHOD, omit_with_wildcard | ||
| from azure.ai.ml._schema.pipeline.pipeline_component import PipelineJobsField | ||
| from devtools_testutils import AzureRecordedTestCase | ||
|
|
||
| from azure.ai.ml import MLClient, load_component | ||
| from azure.ai.ml.dsl import pipeline | ||
| from azure.ai.ml.dsl._condition import condition | ||
|
|
||
|
|
||
| @contextlib.contextmanager | ||
| def include_private_preview_nodes_in_pipeline(): | ||
| original_jobs = PipelineJobSchema._declared_fields["jobs"] | ||
| PipelineJobSchema._declared_fields["jobs"] = PipelineJobsField() | ||
|
|
||
| try: | ||
| yield | ||
| finally: | ||
| PipelineJobSchema._declared_fields["jobs"] = original_jobs | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures( | ||
| "enable_environment_id_arm_expansion", | ||
| "enable_pipeline_private_preview_features", | ||
| "mock_code_hash", | ||
| "mock_component_hash", | ||
| "recorded_test", | ||
| ) | ||
| @pytest.mark.timeout(timeout=_DSL_TIMEOUT_SECOND, method=_PYTEST_TIMEOUT_METHOD) | ||
| @pytest.mark.e2etest | ||
| class TestDynamicPipeline(AzureRecordedTestCase): | ||
| def test_dsl_condition_pipeline(self, client: MLClient): | ||
| # update jobs field to include private preview nodes | ||
|
|
||
| hello_world_component_no_paths = load_component( | ||
| source="./tests/test_configs/components/helloworld_component_no_paths.yml" | ||
| ) | ||
| basic_component = load_component( | ||
| source="./tests/test_configs/components/component_with_conditional_output/spec.yaml" | ||
| ) | ||
|
|
||
| @pipeline( | ||
| name="test_mldesigner_component_with_conditional_output", | ||
| compute="cpu-cluster", | ||
wangchao1230 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| def condition_pipeline(): | ||
| result = basic_component(str_param="abc", int_param=1) | ||
|
|
||
| node1 = hello_world_component_no_paths(component_in_number=1) | ||
| node2 = hello_world_component_no_paths(component_in_number=2) | ||
| condition(condition=result.outputs.output, false_block=node1, true_block=node2) | ||
|
|
||
| pipeline_job = condition_pipeline() | ||
|
|
||
| # include private preview nodes | ||
| with include_private_preview_nodes_in_pipeline(): | ||
| pipeline_job = client.jobs.create_or_update(pipeline_job) | ||
|
|
||
| omit_fields = [ | ||
| "name", | ||
| "properties.display_name", | ||
| "properties.jobs.*.componentId", | ||
| "properties.settings", | ||
| ] | ||
| dsl_pipeline_job_dict = omit_with_wildcard(pipeline_job._to_rest_object().as_dict(), *omit_fields) | ||
| assert dsl_pipeline_job_dict["properties"]["jobs"] == { | ||
| "conditionnode": { | ||
| "condition": "${{parent.jobs.result.outputs.output}}", | ||
| "false_block": "${{parent.jobs.node1}}", | ||
| "true_block": "${{parent.jobs.node2}}", | ||
| "type": "if_else", | ||
| }, | ||
| "node1": { | ||
| "_source": "REMOTE.WORKSPACE.COMPONENT", | ||
| "computeId": None, | ||
| "display_name": None, | ||
| "distribution": None, | ||
| "environment_variables": {}, | ||
| "inputs": {"component_in_number": {"job_input_type": "literal", "value": "1"}}, | ||
| "limits": None, | ||
| "name": "node1", | ||
| "outputs": {}, | ||
| "resources": None, | ||
| "tags": {}, | ||
| "type": "command", | ||
| "properties": {}, | ||
| }, | ||
| "node2": { | ||
| "_source": "REMOTE.WORKSPACE.COMPONENT", | ||
| "computeId": None, | ||
| "display_name": None, | ||
| "distribution": None, | ||
| "environment_variables": {}, | ||
| "inputs": {"component_in_number": {"job_input_type": "literal", "value": "2"}}, | ||
| "limits": None, | ||
| "name": "node2", | ||
| "outputs": {}, | ||
| "resources": None, | ||
| "tags": {}, | ||
| "type": "command", | ||
| "properties": {}, | ||
| }, | ||
| "result": { | ||
| "_source": "REMOTE.WORKSPACE.COMPONENT", | ||
| "computeId": None, | ||
| "display_name": None, | ||
| "distribution": None, | ||
| "environment_variables": {}, | ||
| "inputs": { | ||
| "int_param": {"job_input_type": "literal", "value": "1"}, | ||
| "str_param": {"job_input_type": "literal", "value": "abc"}, | ||
| }, | ||
| "limits": None, | ||
| "name": "result", | ||
| "outputs": {}, | ||
| "resources": None, | ||
| "tags": {}, | ||
| "type": "command", | ||
| "properties": {}, | ||
| }, | ||
| } | ||
|
|
||
| @pytest.mark.skip(reason="TODO(2027778): Verify after primitive condition is supported.") | ||
| def test_dsl_condition_pipeline_with_primitive_input(self, client: MLClient): | ||
| hello_world_component_no_paths = load_component( | ||
| source="./tests/test_configs/components/helloworld_component_no_paths.yml" | ||
| ) | ||
|
|
||
| @pipeline( | ||
| name="test_mldesigner_component_with_conditional_output", | ||
| compute="cpu-cluster", | ||
| ) | ||
| def condition_pipeline(): | ||
| node1 = hello_world_component_no_paths(component_in_number=1) | ||
| node2 = hello_world_component_no_paths(component_in_number=2) | ||
| condition(condition=True, false_block=node1, true_block=node2) | ||
|
|
||
| pipeline_job = condition_pipeline() | ||
| client.jobs.create_or_update(pipeline_job) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.