Skip to content

Commit

Permalink
feat: support name@default
Browse files Browse the repository at this point in the history
use name@label for node component in pipeline yaml
  • Loading branch information
elliotzh committed Oct 19, 2022
1 parent 734f717 commit cbf22bb
Show file tree
Hide file tree
Showing 5 changed files with 598 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
NAMED_RESOURCE_ID_FORMAT = "/subscriptions/{}/resourceGroups/{}/providers/{}/workspaces/{}/{}/{}"
LEVEL_ONE_NAMED_RESOURCE_ID_FORMAT = "/subscriptions/{}/resourceGroups/{}/providers/{}/{}/{}"
VERSIONED_RESOURCE_ID_FORMAT = "/subscriptions/{}/resourceGroups/{}/providers/{}/workspaces/{}/{}/{}/versions/{}"
LABELLED_RESOURCE_ID_FORMAT = "/subscriptions/{}/resourceGroups/{}/providers/{}/workspaces/{}/{}/{}/labels/{}"
DATASTORE_RESOURCE_ID = (
"/subscriptions/{}/resourceGroups/{}/providers/Microsoft.MachineLearningServices/workspaces/{}/datastores/{}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
VERSIONED_RESOURCE_NAME,
LABELLED_RESOURCE_NAME,
AzureMLResourceType,
LABELLED_RESOURCE_ID_FORMAT,
DEFAULT_LABEL_NAME,
)
from azure.ai.ml.entities import Component
from azure.ai.ml.entities._assets import Code, Data, Environment, Model
Expand Down Expand Up @@ -150,6 +152,19 @@ def get_asset_arm_id(
"CLI and SDK. Learn more at aka.ms/curatedenv"
)
return f"azureml:{asset}"

name, label = parse_name_label(asset)
# TODO: remove this condition after label is fully supported for all versioned resources
if label == DEFAULT_LABEL_NAME and azureml_type == AzureMLResourceType.COMPONENT:
return LABELLED_RESOURCE_ID_FORMAT.format(
self._operation_scope.subscription_id,
self._operation_scope.resource_group_name,
AZUREML_RESOURCE_PROVIDER,
self._operation_scope.workspace_name,
azureml_type,
name,
label,
)
name, version = self._resolve_name_version_from_name_label(asset, azureml_type)
if not version:
name, version = parse_prefixed_name_version(asset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,17 @@ def test_remote_pipeline_component_job(self, client: MLClient, randstr: Callable
# assert pipeline_dict["outputs"] == {"output_path": {"mode": "ReadWriteMount", "job_output_type": "uri_folder"}}
assert pipeline_dict["settings"] == {"default_compute": "cpu-cluster", "_source": "REMOTE.WORKSPACE.COMPONENT"}

def test_pipeline_node_with_default_component(self, client: MLClient, randstr: Callable[[str], str]):
params_override = [{"name": randstr("job_name")}]
pipeline_job = load_job(
"./tests/test_configs/pipeline_jobs/helloworld_pipeline_job_with_default_component.yml",
params_override=params_override,
)

created_pipeline_job = client.jobs.create_or_update(pipeline_job)
assert created_pipeline_job.jobs["hello_world_component"].component == \
"microsoftsamples_command_component_basic@default"


@pytest.mark.usefixtures(
"recorded_test",
Expand Down
Loading

0 comments on commit cbf22bb

Please sign in to comment.