Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.53k stars 2.76k forks source link

CodeConfiguration code parameter #34505

Closed fimselamse closed 6 months ago

fimselamse commented 6 months ago

The docstring states

  """Code configuration for a scoring job.

  :param code: The code directory containing the scoring script. The code can be an Code object, an ARM resource ID
      of an existing code asset, a local path, or "http:", "https:", or "azureml:" url pointing to a remote location.
  :type code: Optional[Union[~azure.ai.ml.entities.Code, str]]
  :param scoring_script: The scoring script file path relative to the code directory.
  :type scoring_script: Optional[str]

  .. admonition:: Example:

      .. literalinclude:: ../samples/ml_samples_misc.py
          :start-after: [START code_configuration]
          :end-before: [END code_configuration]
          :language: python
          :dedent: 8
          :caption: Creating a CodeConfiguration for a BatchDeployment.
  """

However, I cannot seem to be able to use any inputs for the code parameter apart from a local path.

When using a storage URI I get the following error

deployment = ManagedOnlineDeployment(
    name=deployment_name,
    endpoint_name=endpoint_name,
    model=model,
    environment=env,
    code_configuration=CodeConfiguration(
        code="https://<storage-account>.blob.core.windows.net/azureml-code-scripts/mlflow_scoring_script",
        scoring_script="scoring.py",

    ),
    instance_type="Standard_DS3_v2",
    instance_count=1,
)

ml_client.online_deployments.begin_create_or_update(
    endpoint_name=endpoint_name,
    deployment=deployment,
)

error: "MlException: Failed to open scoring script [c:\Users\user\\https:\.blob.core.windows.net\azureml-code-scripts\mlflow_scoring_script\scoring.py."

and if instead i try to use a datastore URI i get this error

deployment = ManagedOnlineDeployment(
    name=deployment_name,
    endpoint_name=endpoint_name,
    model=model,
    environment=env,
    code_configuration=CodeConfiguration(
        code="azureml://subscriptions/<subscription-id>/resourcegroups/<resource-group>/workspaces/<workspace>/datastores/scripts/paths/mlflow_scoring_script",
        scoring_script="scoring.py",

    ),
    instance_type="Standard_DS3_v2",
    instance_count=1,
)

error: "Failed to extract version when parsing asset//subscriptions//resourcegroups//workspaces//datastores/scripts/paths/mlflow_scoring_script of type codes as arm id. Version must be provided."

I have also tried registering the asset as a uri_file and use the named asset URI "azureml:mlflow-scoring-script:1", however that doesn't work either.

Am I misunderstanding the docstring completely? Thanks in advance

github-actions[bot] commented 6 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github @diondrapeck @kdestin @luigiw @MilesHolland @needuv @ninghu @paulshealy1 @singankit @YusakuNo1.

github-actions[bot] commented 6 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github @diondrapeck @kdestin @luigiw @MilesHolland @needuv @ninghu @paulshealy1 @singankit @YusakuNo1.

banibrata-de commented 6 months ago

It seems a bug with our current implementation. I have logged to a bug to fix it, however we don't have a timeline for now, to unblock one option would be to use local files.

MakarandBatchu commented 5 months ago

What is the workaround for this issue if I wished to use online custom scoring scripts? @banibrata-de @diondrapeck @kdestin @luigiw @MilesHolland @needuv @ninghu @paulshealy1 @singankit @YusakuNo1 .