Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Local runs are similar in both V1 and V2. Use the "local" string when setting the compute target in either version.
This article gives a comparison of scenarios in SDK v1 and SDK v2.
Submit a local run
Important
The SDK v1 code in this section uses azureml-core, which was deprecated on March 31, 2025. Support ends on June 30, 2026. We recommend transitioning to SDK v2. For more information, see What is Azure Machine Learning CLI and Python SDK v2?
SDK v1
from azureml.core import Workspace, Experiment, Environment, ScriptRunConfig # connect to the workspace ws = Workspace.from_config() # define and configure the experiment experiment = Experiment(workspace=ws, name='day1-experiment-train') config = ScriptRunConfig(source_directory='./src', script='train.py', compute_target='local') # set up pytorch environment env = Environment.from_conda_specification( name='pytorch-env', file_path='pytorch-env.yml') config.run_config.environment = env run = experiment.submit(config) aml_url = run.get_portal_url() print(aml_url)SDK v2
#import required libraries from azure.ai.ml import MLClient, command from azure.ai.ml.entities import Environment from azure.identity import DefaultAzureCredential #connect to the workspace ml_client = MLClient.from_config(credential=DefaultAzureCredential()) # set up pytorch environment env = Environment( image='mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04', conda_file='pytorch-env.yml', name='pytorch-env' ) # define the command command_job = command( code='./src', command='python train.py', environment=env, compute='local', ) returned_job = ml_client.jobs.create_or_update(command_job) returned_job
Mapping of key functionality in SDK v1 and SDK v2
| Functionality in SDK v1 | Rough mapping in SDK v2 |
|---|---|
| experiment.submit | MLClient.jobs.create_or_update |