I was using functionality from last few months, but recently started facing some issue with the below code. I’m running the code using JupyterLab and unable to download the predictions result. However, The batch endpoint is getting invoked and able to stream the job. Additionally, I can see the prediction output saved in Azure Blob Storage.
I’m also not getting any error message.
# invoke the endpoint for batch scoring job
print("Invoking the Batch Endpoint...")
job = ml_client.batch_endpoints.invoke(
endpoint_name=batch_endpoint_name,
input=score_dataset_input,
deployment_name=batch_deployment_name,
params_override=[
{"mini_batch_size": str(mini_batch_size)},
{"compute.instance_count": str(compute_instance_count)},
{"output_file_name": f"{prediction_output_file_name}.csv"}
]
)
print("Batch Endpoint invoked with the provided payload....")
print("Streaming the Job...")
job_name = job.name
batch_job_stream = ml_client.jobs.stream(name=job_name)
# download the job logs and output
ml_client.jobs.download(batch_job.name,
download_path= f"{batch_prediction_dir}/csv/",
output_name="predictions")
2
Answers
Whenever, we invoke batch-endpopint, it will create a new job and save the prediction output at path
f"container_name/{job-run-id}/score"
in workspace default storage.Below is the code, I'm currently using to fetch the prediction output.Thanks @ooxvyd, for suggesting alternate approach:)
It appears that you are attempting to run a batch scoring task in Azure Machine Learning and are having difficulties downloading the prediction results. Given that the batch endpoint is being executed successfully and you can see the prediction output saved in Azure Blob Storage, the problem is most likely in the code used to retrieve the prediction results. Because the code given for obtaining the prediction results lacks context, I’ll present a basic way for downloading files from Azure Blob Storage using Python and the Azure SDK. Assuming
ml_client
is an Azure Machine Learning SDK instance, you may download files from Azure Blob Storage as follows:Replace your particular values for
your_workspace_name>
,your_subscription_id>
,your_resource_group>
,container_name>
,blob_name>
, andlocal_path>
. Check that your JupyterLab environment has the Azure SDK for Python (azureml-sdk
) and Azure Blob Storage (azure-storage-blob
) installed. You may use pip to install them:This code will download the provided blob from Azure Blob Storage to the supplied local directory.