Search code examples
azure-machine-learning-serviceazureml-python-sdk

Get local workspace in azureml


I am trying to run a machine learning experiment in azureml.

I can't figure out how to get the workspace context from the control script. Examples like this one in the microsoft docs use Workspace.from_config(). When I use this in the control script I get the following error:

"message": "We could not find config.json in: [path] or in its parent directories. Please provide the full path to the config file or ensure that config.json exists in the parent directories."

I've also tried including my subscription id and the resource specs like so:

subscription_id = 'id'
resource_group = 'name'
workspace_name = 'name'

workspace = Workspace(subscription_id, resource_group, workspace_name)

In this case I have to monitor the log and authenticate on each run as I would locally.

How do you get the local workspace from a control script for azureml?


Solution

  • This had no answers for 10 months, and now they are coming in :). I figuerd this out quite a while ago but haven't gotten around to posting the answer. Here it is.

    From the training script, you can get the workspace from the run context as follows:

    from azureml.core import Run
    Run.get_context()
    ws = run.experiment.workspace