5

I'm trying to write a script which can download the outputs from an Azure ML experiment Run after the fact.

Essentially, I want to know how I can get a Run by its runId property (or some other identifier).

I am aware that I have access to the Run object when I create it for the purposes of training. What I want is a way to recreate this Run object later in a separate script, possibly from a completely different environment.

What I've found so far is a way to get a list of ScriptRun objects from an experiment via the get_runs() function. But I don't see a way to use one of these ScriptRun objects to create a Run object representing the original Run and allowing me to download the outputs.

Any help appreciated.

1 Answers1

7

I agree that this could probably be better documented, but fortunately, it's a simple implementation.

this is how you get a run object for an already submitted run for azureml-sdk>=1.16.0 (for the older approach see my answer here)

from azureml.core import Workspace

ws = Workspace.from_config()
run = ws.get_run('YOUR_RUN_ID')

once you have the run object, you can call methods like

  • .get_file_names() to see what files are available (the logs in azureml-logs/ and logs/azureml/ will also be listed)
  • .download_file() to download an individual file
  • .download_files() to download all files that match a given prefix (or all the files)

See the Run object docs for more details.

Anders Swanson
  • 3,637
  • 1
  • 18
  • 43
  • 1
    Thank you Anders, that worked a treat. I appreciate the swift response. I guess I was too focused on the apparent nesting of ws -> experiment -> run to think of looking in workspace directly. I think skipping that nesting layer will help me find a few more things I've been looking for too. Thanks again – yesterday's jam Feb 04 '21 at 00:00
  • 1
    yeah the new `get_run` workspace method is snazzy for sure. heads up though that its a whole new ball game when you're passing data between steps of a pipeline. – Anders Swanson Feb 04 '21 at 00:25
  • 1
    Thank you both, just got a task to load traning results to some place else, never used the SDK before (or Azure ML in general), this is what I needed :) – logi0517 Nov 03 '21 at 10:30