I'm trying to start a training job on Azure ML from an Azure function (blob trigger) using Python. Here're the two ways I've seen it done:
- Using the command function from azure.ai.ml
inputs=dict(
data_folder=Input(type="uri_folder", path=web_path)
),
compute=gpu_compute_target,
environment=curated_env_name,
code="./src/",
command="python tf_mnist.py --data-folder ${{inputs.data_folder}}",
experiment_name="tf-dnn-image-classify",
display_name="tensorflow-classify-mnist-digit-images-with-dnn",
)
ml_client.jobs.create_or_update(job)
- Using ScriptRunConfig class from azureml.core
script='train.py',
arguments=['--input-data-dir', dataset.as_named_input('input').as_mount(),
'--reg', '0.99'],
run_config=run_config)
run = experiment.submit(config=src)
What is the difference between these? My source code is in a remote repo and this bit of code would be running in an Azure function. Which of these methods is suitable for my scenario?
CodePudding user response:
They key difference between those methods is just the version of the SDK/API that they are using.
- Code from
azure.ai.ml
is coming from the Python SDK V2, contained in the Python packageazure-ai-ml
. More details about, including how to install it, can be found here - The other code snippet you posted uses the Python SDK V1, contained in the package
azureml-core
. Instructions here.
I would suggest using the V2 SDK, it is clearly more future-proof (though of course you may hit some snags for now because the V2 SDK is still in preview mode). Our team are also now switching from V1 to V2.