Skip to content

Commit e96ff47

Browse files
authored
[ML][Pipelines] Always cancel submitted pipeline jobs (Azure#27638)
* fix: use another registry for pipelines registry tests * test: always cancel job for `assert_job_cancel` * test: remove some fixtures for live only test
1 parent 4499c89 commit e96ff47

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

sdk/ml/azure-ai-ml/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def pipelines_registry_client(e2e_ws_scope: OperationScope, auth: ClientSecretCr
325325
return MLClient(
326326
credential=auth,
327327
logging_enable=getenv(E2E_TEST_LOGGING_ENABLED),
328-
registry_name="sdk-canary",
328+
registry_name="sdk-test",
329329
)
330330

331331

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,27 +1360,20 @@ def test_pipeline_node_with_default_component(self, client: MLClient, randstr: C
13601360
)
13611361

13621362

1363-
1364-
@pytest.mark.usefixtures(
1365-
"recorded_test",
1366-
"mock_code_hash",
1367-
"enable_pipeline_private_preview_features",
1368-
"mock_asset_name",
1369-
"mock_component_hash",
1370-
"enable_environment_id_arm_expansion",
1371-
)
1372-
@pytest.mark.timeout(timeout=_PIPELINE_JOB_LONG_RUNNING_TIMEOUT_SECOND, method=_PYTEST_TIMEOUT_METHOD)
1363+
@pytest.mark.usefixtures("enable_pipeline_private_preview_features")
13731364
@pytest.mark.e2etest
13741365
@pytest.mark.pipeline_test
13751366
@pytest.mark.skipif(condition=not is_live(), reason="no need to run in playback mode")
1376-
class TestPipelineJobLongRunning(AzureRecordedTestCase):
1367+
@pytest.mark.timeout(timeout=_PIPELINE_JOB_LONG_RUNNING_TIMEOUT_SECOND, method=_PYTEST_TIMEOUT_METHOD)
1368+
class TestPipelineJobLongRunning:
13771369
"""Long-running tests that require pipeline job completed."""
13781370
def test_pipeline_job_get_child_run(self, client: MLClient, randstr: Callable[[str], str]):
13791371
pipeline_job = load_job(
13801372
source="./tests/test_configs/pipeline_jobs/helloworld_pipeline_job_quick_with_output.yml",
13811373
params_override=[{"name": randstr("name")}],
13821374
)
13831375
job = client.jobs.create_or_update(pipeline_job)
1376+
print("pipeline job name:", job.name)
13841377
wait_until_done(client, job)
13851378
child_job = next(
13861379
job
@@ -1400,6 +1393,7 @@ def test_pipeline_job_download(
14001393
params_override=[{"name": randstr("job_name")}],
14011394
)
14021395
)
1396+
print("pipeline job name:", job.name)
14031397
wait_until_done(client, job)
14041398
client.jobs.download(name=job.name, download_path=tmp_path)
14051399
artifact_dir = tmp_path / "artifacts"
@@ -1415,6 +1409,7 @@ def test_pipeline_job_child_run_download(
14151409
params_override=[{"name": randstr("job_name")}],
14161410
)
14171411
)
1412+
print("pipeline job name:", job.name)
14181413
wait_until_done(client, job)
14191414
child_job = next(
14201415
job
@@ -1434,7 +1429,6 @@ def test_pipeline_job_child_run_download(
14341429
assert output_dir.exists()
14351430
assert next(output_dir.iterdir(), None), "No artifacts were downloaded"
14361431

1437-
@pytest.mark.disable_mock_code_hash
14381432
def test_reused_pipeline_child_job_download(
14391433
self,
14401434
client: MLClient,
@@ -1445,15 +1439,15 @@ def test_reused_pipeline_child_job_download(
14451439

14461440
# ensure previous job exists for reuse
14471441
job_name = randstr("job_name")
1448-
print(f"previous job name: {job_name}")
1442+
print("previous job name:", job_name)
14491443
previous_job = client.jobs.create_or_update(
14501444
load_job(source=pipeline_spec_path, params_override=[{"name": job_name}])
14511445
)
14521446
wait_until_done(client, previous_job)
14531447

14541448
# submit a new job that will reuse previous job
14551449
new_job_name = randstr("new_job_name")
1456-
print(f"new job name: {new_job_name}")
1450+
print("new job name:", new_job_name)
14571451
new_job = client.jobs.create_or_update(
14581452
load_job(pipeline_spec_path, params_override=[{"name": new_job_name}]),
14591453
)

sdk/ml/azure-ai-ml/tests/test_utilities/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def assert_job_cancel(
292292
created_job = client.jobs.create_or_update(job, experiment_name=experiment_name)
293293
if check_before_cancelled is not None:
294294
assert check_before_cancelled(created_job)
295-
cancel_job(client, created_job)
295+
cancel_job(client, created_job)
296296
return created_job
297297

298298

0 commit comments

Comments
 (0)