Table of Contents

How to retrieve the current workspace from a remote Run context

ws = Run.get_context().experiment.workspace

Useful in pipelines, see this article for a complete example.

How to download a model from the models repository

model_ws = Model(ws, '<your-model-name>')
pickled_model_path = = True)

model = joblib.load(pickled_model_path)


Testing pipeline steps locally

This mostly works with the current version of the SDK, however when trying to access stuff like the current experiment or its workspace we get a nice AttributeError: '_OfflineRun' object has no attribute 'experiment'. You can prevent this by checking if the experiment property exists and initialize the workspace from a local config.json if it doesn’t.

aml_context = Run.get_context()
# assumes a config.json file exists in the current or the parent directory
ws = Workspace.from_config() if not hasattr(aml_context, 'experiment') else aml_context.experiment.workspace

Alternate way which looks better to me as a C# dev, but I can’t stop wondering if it’s pythonic enough. 🤨

from import _OfflineRun

aml_context = Run.get_context()
ws = Workspace.from_config() if type(aml_context) == _OfflineRun else aml_context.experiment.workspace

Requesting a compute quota increase

By default you get 10 cores, which may or may not be enough. You can increase them by contacting support, see this and this for details.

Authenticating to a different tenant than usual

from azureml.core import Workspace
from azureml.core.authentication import InteractiveLoginAuthentication

forced_interactive_auth = InteractiveLoginAuthentication(tenant_id='your-tenant-id', force=True)
ws = Workspace.from_config(auth=forced_interactive_auth)

– via Azure Machine Learning Notebooks