From 7350a3237d034077dcb55e37226b0018fd99cb4e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 02:27:29 +0000 Subject: [PATCH 1/3] Initial plan From f6f9ead6553162b96bfe73e480fa713fe9b616f5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 02:32:41 +0000 Subject: [PATCH 2/3] Handle missing file references in FileRefField as ValidationError and add schedule test Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/6caa9bff-e084-4c8f-affd-c426ef4c1912 Co-authored-by: lavakumarrepala <221403938+lavakumarrepala@users.noreply.github.com> --- sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py | 5 ++++- .../tests/schedule/unittests/test_schedule_schema.py | 10 ++++++++++ .../hello_cron_schedule_with_missing_job_file.yml | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 sdk/ml/azure-ai-ml/tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py index fd7956b85bb0..28147fac2875 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py @@ -369,7 +369,10 @@ def _deserialize(self, value, attr, data, **kwargs): if not path.is_absolute(): path = base_path / path path.resolve() - data = load_file(path) + try: + data = load_file(path) + except (FileNotFoundError, OSError) as e: + raise ValidationError(f"No such file or directory: {path}") from e return data raise ValidationError(f"Not supporting non file for {attr}") diff --git a/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py b/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py index 2bf677c8503a..92eeb36447bb 100644 --- a/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py +++ b/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py @@ -157,3 +157,13 @@ def test_load_invalid_schedule_missing_type(self): with pytest.raises(ValidationError) as e: load_schedule(test_path) assert "'type' must be specified when scheduling a remote job with updates." in e.value.messages[0] + + def test_load_invalid_schedule_with_missing_job_file(self): + test_path = "./tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml" + with pytest.raises(ValidationError) as e: + load_schedule(test_path) + error_message = str(e.value) + assert "No such file or directory:" in error_message + assert "missing_pipeline.yml" in error_message + assert "In order to specify an existing jobs" not in error_message + assert "Not supporting non file for create_job" not in error_message diff --git a/sdk/ml/azure-ai-ml/tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml b/sdk/ml/azure-ai-ml/tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml new file mode 100644 index 000000000000..09f9fc80f952 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml @@ -0,0 +1,11 @@ +$schema: http://azureml/sdk-2-0/Schedule.json +name: weekly_retrain_2022_missing_file +display_name: weekly retrain schedule +description: a weekly retrain schedule + +trigger: + type: cron + expression: "15 10 * * 1" + start_time: "2022-03-10T10:15:00" + +create_job: ./missing_pipeline.yml From 5e587c3e252bd65215180cd8e5b8ef3c8d11dc39 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 02:33:17 +0000 Subject: [PATCH 3/3] Rename missing create_job file schedule test for clarity Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/6caa9bff-e084-4c8f-affd-c426ef4c1912 Co-authored-by: lavakumarrepala <221403938+lavakumarrepala@users.noreply.github.com> --- .../tests/schedule/unittests/test_schedule_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py b/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py index 92eeb36447bb..3fe72131d613 100644 --- a/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py +++ b/sdk/ml/azure-ai-ml/tests/schedule/unittests/test_schedule_schema.py @@ -158,7 +158,7 @@ def test_load_invalid_schedule_missing_type(self): load_schedule(test_path) assert "'type' must be specified when scheduling a remote job with updates." in e.value.messages[0] - def test_load_invalid_schedule_with_missing_job_file(self): + def test_load_schedule_with_missing_create_job_file(self): test_path = "./tests/test_configs/schedule/invalid/hello_cron_schedule_with_missing_job_file.yml" with pytest.raises(ValidationError) as e: load_schedule(test_path)