I'm using azureml sdk2 and I want to add execution cancel condition to my code but I don't know how to do it?
from azure.ai.ml import MLClient
ml_client = MLClient(
credential=credential,
subscription_id = "***",
resource_group_name = "***",
workspace_name = "***"
)
job = command(
code="./temp-workspace/", # location of source code
command="python train_script.py",
description = description,
tags=tags,
environment=myenv,
compute=cpu_compute_target,
experiment_name=experiment_name,
display_name=registered_model_name,
)
# submit the command
returned_job = ml_client.jobs.create_or_update(job)
how can i cancel this job in local run?
To cancel the job with
ml_clientyou can use below code snippet:Job started and cancelled with
ml_clientas shown:With above code the job was cancelled as per requirement.