Skip to content

Commit 7ff8b6e

Browse files
authored
fix: resolve jobs.xxx.inputs for subgraph (Azure#32168)
1 parent 7abd040 commit 7ff8b6e

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_component_operations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def _try_resolve_environment_for_component(cls, component, _: str, resolver: _As
760760
def _resolve_azureml_id(self, component: Component, jobs_only: bool = False) -> None:
761761
# TODO: remove the parameter `jobs_only`. Some tests are expecting an arm id after resolving for now.
762762
resolver = self._orchestrators.resolve_azureml_id
763-
self._resolve_dependencies_for_component(component, resolver, resolve_jobs_inputs=True, jobs_only=jobs_only)
763+
self._resolve_dependencies_for_component(component, resolver, jobs_only=jobs_only)
764764

765765
def _resolve_arm_id_or_upload_dependencies(self, component: Component) -> None:
766766
resolver = OperationOrchestrator(
@@ -774,7 +774,6 @@ def _resolve_dependencies_for_component(
774774
component: Component,
775775
resolver: Callable,
776776
*,
777-
resolve_jobs_inputs: bool = False,
778777
jobs_only: bool = False,
779778
) -> None:
780779
# for now, many tests are expecting long arm id instead of short id for environment and code
@@ -805,7 +804,6 @@ def _resolve_dependencies_for_component(
805804
self._resolve_dependencies_for_pipeline_component_jobs(
806805
component,
807806
resolver=resolver,
808-
resolve_inputs=resolve_jobs_inputs,
809807
)
810808

811809
def _resolve_inputs_for_pipeline_component_jobs(self, jobs: Dict[str, Any], base_path: str):
@@ -1049,7 +1047,9 @@ def _get_client_key(self) -> str:
10491047
return self._client_key
10501048

10511049
def _resolve_dependencies_for_pipeline_component_jobs(
1052-
self, component: Union[Component, str], resolver: _AssetResolver, *, resolve_inputs: bool = True
1050+
self,
1051+
component: Union[Component, str],
1052+
resolver: _AssetResolver,
10531053
):
10541054
"""Resolve dependencies for pipeline component jobs.
10551055
Will directly return if component is not a pipeline component.
@@ -1066,8 +1066,7 @@ def _resolve_dependencies_for_pipeline_component_jobs(
10661066

10671067
from azure.ai.ml.entities._job.automl.automl_job import AutoMLJob
10681068

1069-
if resolve_inputs:
1070-
self._resolve_inputs_for_pipeline_component_jobs(component.jobs, component._base_path)
1069+
self._resolve_inputs_for_pipeline_component_jobs(component.jobs, component._base_path)
10711070

10721071
# This is a preparation for concurrent resolution. Nodes will be resolved later layer by layer
10731072
# from bottom to top, as hash calculation of a parent node will be impacted by resolution

sdk/ml/azure-ai-ml/tests/component/e2etests/test_component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ def test_simple_pipeline_component_create(self, client: MLClient, randstr: Calla
832832
)
833833
# Assert binding on compute not changed after resolve dependencies
834834
client.components._resolve_dependencies_for_pipeline_component_jobs(
835-
component, resolver=client.components._orchestrators.get_asset_arm_id, resolve_inputs=False
835+
component, resolver=client.components._orchestrators.get_asset_arm_id
836836
)
837837
assert component.jobs["component_a_job"].compute == "${{parent.inputs.node_compute}}"
838838
# Assert E2E

sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_dsl_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ def valid_pipeline_func(
11321132

11331133
# Assert binding on compute not changed after resolve dependencies
11341134
client.components._resolve_dependencies_for_pipeline_component_jobs(
1135-
component, resolver=client.components._orchestrators.get_asset_arm_id, resolve_inputs=False
1135+
component, resolver=client.components._orchestrators.get_asset_arm_id
11361136
)
11371137
assert component.jobs["node2"].compute == "${{parent.inputs.node_compute}}"
11381138

sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_dsl_pipeline_with_specific_nodes.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from dataclasses import field
21
from functools import partial
32
from pathlib import Path
43
from typing import Callable, Union
54

65
import pytest
7-
from devtools_testutils import AzureRecordedTestCase
6+
from devtools_testutils import AzureRecordedTestCase, is_live
87
from mock import mock
98
from pytest_mock import MockFixture
109
from test_utilities.utils import (
@@ -394,3 +393,27 @@ def pipeline_with_command(input_data):
394393
"component_in_group.number": {"job_input_type": "literal", "value": "1.0"},
395394
"component_in_group.sub1.integer": {"job_input_type": "literal", "value": "1"},
396395
}
396+
397+
@pytest.mark.skipif(not is_live(), reason="Met some problem in recording")
398+
def test_dsl_pipeline_component_with_static_local_data_input(self, client: MLClient) -> None:
399+
path = "./tests/test_configs/components/helloworld_component.yml"
400+
input_data_path = "./tests/test_configs/data/"
401+
402+
@dsl.pipeline()
403+
def pipeline_no_arg():
404+
component_func = load_component(source=path)
405+
component_func(
406+
component_in_path=Input(
407+
path=input_data_path,
408+
type=AssetTypes.URI_FOLDER,
409+
),
410+
component_in_number=1,
411+
)
412+
413+
@dsl.pipeline
414+
def pipeline_func():
415+
pipeline_no_arg()
416+
417+
pipeline_job: PipelineJob = pipeline_func()
418+
pipeline_job.settings.default_compute = "cpu-cluster"
419+
client.jobs.create_or_update(pipeline_job)

0 commit comments

Comments
 (0)