Skip to content

Commit 698471b

Browse files
authored
fix: keep False values in pipeline_job.settings (#28524)
1 parent 0bf8db1 commit 698471b

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
### Bugs Fixed
99
- Fixed an issue where the ordering of `.amlignore` and `.gitignore` files are not respected
10+
- Fixed an issue that attributes with a value of `False` in `PipelineJobSettings` are not respected
1011

1112
### Other Changes
1213
- Update workspace creation to use Log Analytics-Based Application Insights when the user does not specify/bring their own App Insights.

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_job/pipeline.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class PipelineConstants:
99
DEFAULT_DATASTORE = "default_datastore"
1010
DEFAULT_COMPUTE = "default_compute"
1111
CONTINUE_ON_STEP_FAILURE = "continue_on_step_failure"
12+
CONTINUE_RUN_ON_FAILED_OPTIONAL_INPUT = "continue_run_on_failed_optional_input"
1213
DATASTORE_REST = "Datastore"
1314
ENVIRONMENT = "environment"
1415
CODE = "code"

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_attr_dict.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def _get_attrs(self) -> dict:
6565
def remove_empty_values(data):
6666
if not isinstance(data, dict):
6767
return data
68-
return {k: remove_empty_values(v) for k, v in data.items() if v}
68+
# skip empty dicts as default value of _AttrDict is empty dict
69+
return {k: remove_empty_values(v) for k, v in data.items() if v or not isinstance(v, dict)}
6970

7071
return remove_empty_values(self)
7172

sdk/ml/azure-ai-ml/tests/dsl/unittests/test_attr_dict.py

+5
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,8 @@ def test_attr_dict_as_bool(self):
8181
assert not obj
8282
obj.continue_on_step_failure = False
8383
assert obj
84+
85+
def test_attr_dict_false_value(self):
86+
obj = _AttrDict()
87+
obj.false_value = False
88+
assert obj._get_attrs() == {"false_value": False}

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

+24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import pydash
99
import pytest
10+
11+
from azure.ai.ml.constants._job import PipelineConstants
1012
from test_configs.dsl_pipeline import data_binding_expression
1113
from test_utilities.utils import omit_with_wildcard, prepare_dsl_curated
1214

@@ -2596,3 +2598,25 @@ def my_pipeline() -> Output(type="uri_folder", description="new description", mo
25962598
'description': 'new description', 'job_output_type': 'uri_folder', 'mode': 'Upload'
25972599
}}
25982600
assert pipeline_job._to_rest_object().as_dict()["properties"]["outputs"] == expected_outputs
2601+
2602+
def test_dsl_pipeline_run_settings(self) -> None:
2603+
hello_world_component_yaml = "./tests/test_configs/components/helloworld_component.yml"
2604+
hello_world_component_func = load_component(source=hello_world_component_yaml)
2605+
2606+
@dsl.pipeline()
2607+
def my_pipeline() -> Output(type="uri_folder", description="new description", mode="upload"):
2608+
node = hello_world_component_func(component_in_path=Input(path="path/on/ds"), component_in_number=10)
2609+
return {"output": node.outputs.component_out_path}
2610+
2611+
pipeline_job: PipelineJob = my_pipeline()
2612+
pipeline_job.settings.default_compute = "cpu-cluster"
2613+
pipeline_job.settings.continue_on_step_failure = True
2614+
pipeline_job.settings.continue_run_on_failed_optional_input = False
2615+
2616+
assert pipeline_job._to_rest_object().properties.settings == {
2617+
PipelineConstants.DEFAULT_COMPUTE: "cpu-cluster",
2618+
PipelineConstants.CONTINUE_ON_STEP_FAILURE: True,
2619+
PipelineConstants.CONTINUE_RUN_ON_FAILED_OPTIONAL_INPUT: False,
2620+
"_source": "DSL"
2621+
}
2622+

0 commit comments

Comments
 (0)