azure-sdk-for-python: Unable to download file from output of job using mlclient - Azure python sdk v2

  • Package Name: azure-ai-ml
  • Package Version: 1.12.1
  • Operating System:linux
  • Python Version: 3.9

Describe the bug Unable to download a file from the outputs which are generated after job is completed.

ml_client.jobs.download(name=job_name)

Using the above code I am able to download all the files which are there in the outputs. And the azure blob path from where it is downloaded is azureml://datastores/workspaceartifactstore/ExperimentRun/dcid.job_name

When I mention a specific file to download like ml_client.jobs.download(name=job_name,output_name=file_name) then is looking at different data store that is azureml://datastores/workspaceblobstore/paths/azureml/job_name/file_name, But actually the file is in different location.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 15 (5 by maintainers)

Most upvoted comments

I’m also affected by this bug.

Here’s my workaround:

from pathlib import Path

from azure.ai.ml import MLClient
from azure.ai.ml._artifacts._artifact_utilities import download_artifact_from_aml_uri


def _build_aml_file_uri(run_id: str, aml_path: Path) -> str:
    base_uri = "azureml://datastores/workspaceartifactstore/ExperimentRun"
    uri = f"{base_uri}/dcid.{run_id}/{aml_path}"
    return uri


def download_file_from_run(
    ml_client: MLClient,
    run_id: str,
    aml_path: Path,
    out_dir: Path,
) -> Path:
    uri = _build_aml_file_uri(run_id, aml_path)
    download_artifact_from_aml_uri(
        uri=uri,
        destination=str(out_dir),
        datastore_operation=ml_client.jobs._datastore_operations,
    )
    return out_dir / aml_path.name

Thanks for the logs, looks like we have a bug to fix for single file. However, right now don’t have an ETA for this. Until then please use download all files or you may want to download a single file from Azure ML studio portal.