Skip to content

Commit aa80d7f

Browse files
committed
feat: ignore unknown fields on internal output port definition instead of raising error
1 parent ce859ba commit aa80d7f

File tree

47 files changed

+5844
-5731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+5844
-5731
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_internal/_schema/component.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44

5-
from marshmallow import fields, post_dump
5+
from marshmallow import fields, post_dump, EXCLUDE
66

77
from azure.ai.ml._schema import NestedField, StringTransformedEnum, UnionField
88
from azure.ai.ml._schema.component.component import ComponentSchema
@@ -66,8 +66,8 @@ class InternalBaseComponentSchema(ComponentSchema):
6666
keys=fields.Str(),
6767
values=UnionField(
6868
[
69-
NestedField(InternalPrimitiveOutputSchema),
70-
NestedField(InternalOutputPortSchema),
69+
NestedField(InternalPrimitiveOutputSchema, unknown=EXCLUDE),
70+
NestedField(InternalOutputPortSchema, unknown=EXCLUDE),
7171
]
7272
),
7373
)

sdk/ml/azure-ai-ml/tests/internal/_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
PARAMETERS_TO_TEST = [
1212
# which of them are available for other components?
1313
(
14-
"tests/test_configs/internal/ls_command_component.yaml",
14+
"tests/test_configs/internal/command-component-ls/ls_command_component.yaml",
1515
{},
1616
{
1717
"compute": "cpu-cluster", # runsettings.target

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ def test_component_load(
8787
component_resource = create_component(client, component_name, path=yaml_path)
8888
loaded_dict = load_registered_component(client, component_name, component_resource.version, omit_fields)
8989

90-
json_path = yaml_path.rsplit(".", 1)[0] + ".loaded_from_rest.json"
90+
base_dir = "./tests/test_configs/internal"
91+
json_path = (yaml_path.rsplit(".", 1)[0] + ".json")
92+
json_path = os.path.join(base_dir, "loaded_from_rest", os.path.relpath(json_path, base_dir))
93+
os.makedirs(os.path.dirname(json_path), exist_ok=True)
9194
if not os.path.isfile(json_path):
9295
with open(json_path, "w") as f:
9396
json.dump(loaded_dict, f, indent=2)

sdk/ml/azure-ai-ml/tests/internal/e2etests/test_pipeline_job.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def pipeline_func():
105105
"yaml_path,inputs,runsettings_dict,pipeline_runsettings_dict",
106106
PARAMETERS_TO_TEST,
107107
)
108-
def test_anonymous_internal_component_in_pipeline(
108+
def test_pipeline_anonymous(
109109
self, client: MLClient, yaml_path, inputs, runsettings_dict, pipeline_runsettings_dict
110110
):
111111
# curated env with name & version

sdk/ml/azure-ai-ml/tests/internal/unittests/test_component.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_load_v2_component(self):
3131

3232
def test_specific_error_message_on_load_from_dict(self):
3333
os.environ[AZUREML_INTERNAL_COMPONENTS_ENV_VAR] = "false"
34-
yaml_path = "./tests/test_configs/internal/helloworld_component_command.yml"
34+
yaml_path = "./tests/test_configs/internal/helloworld/helloworld_component_command.yml"
3535
with pytest.raises(
3636
ValidationException,
3737
match="Internal components is a private feature in v2, " "please set environment variable",
@@ -439,6 +439,10 @@ def test_component_output_with_attrs(self) -> None:
439439
assert component
440440

441441
expected_outputs = {
442+
"path_with_optional": {
443+
# unknown field optional will be ignored
444+
"type": 'AnyDirectory',
445+
},
442446
"primitive_is_control": {
443447
"is_control": True,
444448
"type": "boolean",
@@ -464,7 +468,7 @@ def test_loop_node_is_internal_components(self):
464468
from azure.ai.ml.constants._common import AZUREML_INTERNAL_COMPONENTS_ENV_VAR
465469
from azure.ai.ml.dsl._utils import environment_variable_overwrite
466470

467-
yaml_path = "./tests/test_configs/internal/helloworld_component_command.yml"
471+
yaml_path = "./tests/test_configs/internal/helloworld/helloworld_component_command.yml"
468472
component_func = load_component(source=yaml_path)
469473
loop_node = LoopNode(body=component_func())
470474
loop_node.body._referenced_control_flow_node_instance_id = loop_node._instance_id

sdk/ml/azure-ai-ml/tests/internal/unittests/test_pipeline_job.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def pipeline_func(pipeline_input):
164164

165165
@pytest.mark.usefixtures("enable_pipeline_private_preview_features")
166166
def test_internal_component_output_as_pipeline_component_output(self):
167-
yaml_path = "./tests/test_configs/internal/component_with_input_types/component_spec.yaml"
167+
yaml_path = "./tests/test_configs/internal/component_with_input_outputs/component_spec.yaml"
168168
component_func = load_component(yaml_path, params_override=[{"inputs": {}}])
169169

170170
@pipeline()
@@ -220,7 +220,7 @@ def pipeline_func():
220220
assert result._to_dict() == {"result": "Succeeded"}
221221

222222
def test_gjd_internal_component_in_pipeline(self):
223-
yaml_path = "./tests/test_configs/internal/ls_command_component.yaml" # GJD is based on CommandComponent
223+
yaml_path = "./tests/test_configs/internal/command-component-ls/ls_command_component.yaml" # GJD is based on CommandComponent
224224
node_func: CommandComponent = load_component(yaml_path)
225225
node = node_func()
226226

@@ -246,7 +246,7 @@ def test_gjd_internal_component_in_pipeline(self):
246246

247247
def test_elastic_component_in_pipeline(self):
248248
yaml_path = (
249-
"./tests/test_configs/internal/ls_command_component.yaml" # itp & elastic are based on CommandComponent
249+
"./tests/test_configs/internal/command-component-ls/ls_command_component.yaml" # itp & elastic are based on CommandComponent
250250
)
251251
node_func: CommandComponent = load_component(yaml_path)
252252
node = node_func()
@@ -303,7 +303,7 @@ def test_elastic_component_in_pipeline(self):
303303

304304
def test_singularity_component_in_pipeline(self):
305305
yaml_path = (
306-
"./tests/test_configs/internal/ls_command_component.yaml" # singularity is based on CommandComponent
306+
"./tests/test_configs/internal/command-component-ls/ls_command_component.yaml" # singularity is based on CommandComponent
307307
)
308308
node_func: CommandComponent = load_component(yaml_path)
309309
node = node_func()
@@ -366,7 +366,7 @@ def test_singularity_component_in_pipeline(self):
366366
}
367367

368368
def test_load_pipeline_job_with_internal_components_as_node(self):
369-
yaml_path = Path("./tests/test_configs/internal/helloworld_component_scope.yml")
369+
yaml_path = Path("./tests/test_configs/internal/helloworld/helloworld_component_scope.yml")
370370
scope_internal_func = load_component(source=yaml_path)
371371
with open(yaml_path, encoding="utf-8") as yaml_file:
372372
yaml_dict = yaml.safe_load(yaml_file)
@@ -472,7 +472,7 @@ def pipeline_func():
472472
assert dsl_pipeline._to_dict() == regenerated_pipeline_job._to_dict()
473473

474474
def test_components_input_output(self):
475-
yaml_path = "./tests/test_configs/internal/component_with_input_types/component_spec.yaml"
475+
yaml_path = "./tests/test_configs/internal/component_with_input_outputs/component_spec.yaml"
476476
component: InternalComponent = load_component(yaml_path)
477477

478478
fake_input = Input(type=AssetTypes.MLTABLE, path="azureml:scope_tsv:1")
@@ -529,7 +529,7 @@ def pipeline_func():
529529
assert rest_obj.properties.jobs["node"]["inputs"] == expected_inputs
530530

531531
def test_data_binding_on_node_runsettings(self):
532-
test_path = "./tests/test_configs/internal/helloworld_component_command.yml"
532+
test_path = "./tests/test_configs/internal/helloworld/helloworld_component_command.yml"
533533
component: InternalComponent = load_component(test_path)
534534

535535
@pipeline()

0 commit comments

Comments
 (0)