Skip to content

Commit 10a2303

Browse files
lllilithyangchenyangliao
andauthored
Improve error message in download when use invalid input (Azure#28992)
* add name and version for output * add asset_name, asset_version, merge 2022-12-01 pr * resolve comments * add test and modify related codes * refine code * fix failed test * fix comments * fix condition._port_name * fix test and some comments * revert the modification of compute * fix comments * fix pylint error, add tests for CommandJob, Spark, Parallel, Sweep * delete one test, will add in another pr * modify error message * improve error msg, add ut * run black --------- Co-authored-by: chenyangliao <chenyangliao@microsoft.com>
1 parent 20bf5d1 commit 10a2303

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
PipelineChildJobError,
8888
ValidationErrorType,
8989
ValidationException,
90+
UserErrorException,
9091
)
9192
from azure.ai.ml.operations._run_history_constants import RunHistoryConstants
9293
from azure.ai.ml.sweep import SweepJob
@@ -276,6 +277,8 @@ def get(self, name: str) -> Job:
276277
:rtype: Job
277278
:raise: ResourceNotFoundError if can't find a job matching provided name.
278279
"""
280+
if not isinstance(name, str):
281+
raise UserErrorException(f"{name} is a invalid input for client.jobs.get().")
279282
job_object = self._get_job(name)
280283

281284
if not _is_pipeline_child_job(job_object):

sdk/ml/azure-ai-ml/tests/job_common/unittests/test_job_operations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,8 @@ def test_job_create_skip_validation(self, mock_method, mock_job_operation: JobOp
254254
mock_thing.assert_not_called()
255255
mock_job_operation.create_or_update(job=job)
256256
mock_thing.assert_called_once()
257+
258+
def test_download_with_none(self, mock_job_operation: JobOperations) -> None:
259+
with pytest.raises(Exception) as ex:
260+
mock_job_operation.download(None)
261+
assert "None is a invalid input for client.jobs.get()." in ex.value.message

0 commit comments

Comments
 (0)