Azure ML: how to use remote location as code path?

79 Views Asked by At

I am using Azure ML python SDK v2 to submit the job. The code parameter at "command" is pointed to the local "./source" path.

train_func = command(
       environment="AzureML-sklearn-1.0-ubuntu20.04-py38-cpu:33",
       command='python myfunc.py ...',
       code='./source',
       ...
   )

How to use remote location as code path in the above example? I read the reference azure-ai-ml and it shows the code can be a remote location:

code Optional[Union[str, PathLike]] The source code to run the job. Can be a local path or "http:", "https:", or "azureml:" url pointing to a remote location.

I tried use the pathtext-like "azureml://" from AzureDataStore URI but not working.

1

There are 1 best solutions below

1
Rishabh Meshram On

I have uploaded the source code using below code snippet:

from azure.ai.ml.entities import Data
from azure.ai.ml.constants import AssetTypes

my_path = "./src"
# set the version number of the data asset
v1 = "initial"

my_data = Data(
    name="source",
    version=v1,
    description="Code",
    path=my_path,
    type=AssetTypes.URI_FOLDER,
)
try:
    data_asset = ml_client.data.get(name="source", version=v1)
    print(f"Data asset already exists. Name: {my_data.name}, version: {my_data.version}")
except:
    ml_client.data.create_or_update(my_data)
    print(f"Data asset created. Name: {my_data.name}, version: {my_data.version}")

Once uploaded, I have used Storage URI as the remote code path. enter image description here

With this, the job is executed successfully. enter image description here