skip to Main Content

I have a scheduled AzureML pipeline. Every run of the pipeline gets an autogenerated name in the AzureML UI. I’d like to pass this name to the pipeline. How could I do that?

The scheduled pipeline is created as follows:

step = CommandStep(command="myscript.sh --job-name=<AZUREML JOB NAME>")
pipeline = Pipeline(workspace, [step])
published_pipeline = pipeline.publish(name='my pipeline')
schedule = Schedule.create(workspace=workspace, pipeline_id=published_pipeline.id, ...)

I would like to pass the run name create by AzureML e.g. as a command line parameter as in the example above.

2

Answers


  1. Chosen as BEST ANSWER

    From within an AzureML pipeline (SDK v2), you can read the run_id from an environment variable and then get the display name as follows

    client = MLClient( ... )
    job = client.jobs.get(os.environ["AZUREML_RUN_ID"])
    job.display_name
    

  2. The pipeline is referenced with run id/job name.

    enter image description here

    If you are using sdk v2, use below code.

    pipeline_job = ml_client.jobs.create_or_update(
    pipeline_job, experiment_name="17 dec"
    )
    pipeline_job.name
    

    Here, you use the pipeline job object after submitting the job to get the job name.

    Output:
    enter image description here

    OR

    In sdk v1

    run = Run.get_context()
    run_id = run.id
    

    Next, pass this id to your step job.

    step = CommandStep(command=f"myscript.sh --job-name={run_id }")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search