Skip to content

Commit

Permalink
fix od batch scoring notebook (Azure#2220)
Browse files Browse the repository at this point in the history
* fix od batch scoring notebook

* format file

* update broken path
  • Loading branch information
sharma-riti committed Apr 21, 2023
1 parent 5210e44 commit 88ab31e
Showing 1 changed file with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@
"## 6.2 Configure environment\n",
"It is recommended to use the same envionment for model deployment as the model training, therefore we are creating the Environment object using the conda environment file downloaded as artifacts. We also need to specify the base image, which in case of vision tasks, is `mcr.microsoft.com/azureml/openmpi4.1.0-cuda11.1-cudnn8-ubuntu18.04`\n",
"\n",
"To read more about environments, please follow this [notebook](./../../assets/environment/environment.ipynb)"
"To read more about environments, please follow this [notebook](./../../../assets/environment/environment.ipynb)"
]
},
{
Expand All @@ -813,7 +813,7 @@
"env = Environment(\n",
" name=\"automl-images-env\",\n",
" description=\"environment for automl images inference\",\n",
" image=\"mcr.microsoft.com/azureml/openmpi4.1.0-cuda11.1-cudnn8-ubuntu18.04\",\n",
" image=\"mcr.microsoft.com/azureml/openmpi4.1.0-cuda11.1-cudnn8-ubuntu20.04\",\n",
" conda_file=\"artifact_downloads/outputs/conda_env_v_1_0_0.yml\",\n",
")"
]
Expand Down Expand Up @@ -1079,7 +1079,7 @@
"# get the details of the job\n",
"job_name = job.name\n",
"batch_job = ml_client.jobs.get(name=job_name)\n",
"print(batch_job.status)\n",
"print(batch_job)\n",
"# stream the job logs\n",
"ml_client.jobs.stream(name=job_name)"
]
Expand All @@ -1097,13 +1097,42 @@
"metadata": {},
"outputs": [],
"source": [
"output_dir = \"./scoring_results\"\n",
"ml_client.jobs.download(\n",
" name=job.name, output_name=deployment.output_file_name, download_path=output_dir\n",
"from azureml.core import Experiment, Workspace\n",
"from azureml.pipeline.core import PipelineRun, StepRun, PortDataReference\n",
"\n",
"workspace_obj = Workspace(\n",
" subscription_id=ml_client.subscription_id,\n",
" resource_group=ml_client.resource_group_name,\n",
" workspace_name=ml_client.workspace_name,\n",
")\n",
"\n",
"# Get the Pipeline Run\n",
"experiment = Experiment(workspace=workspace_obj, name=batch_job.experiment_name)\n",
"pipeline_run = PipelineRun(experiment, batch_job.name)\n",
"\n",
"# Get the Step Run\n",
"step_run_id = pipeline_run.find_step_run(\"BatchScoring\")[0].id\n",
"node_id = pipeline_run.get_graph().node_name_dict[\"BatchScoring\"][0].node_id\n",
"print(\n",
" \"Pipeline Run ID: {} Step Run ID: {}, Step Run Node ID: {}\".format(\n",
" pipeline_run.id, step_run_id, node_id\n",
" )\n",
")\n",
"step_run = StepRun(experiment, step_run_id, pipeline_run.id, node_id)\n",
"\n",
"# Download Data\n",
"port_data_reference = step_run.get_output_data(\"score\")\n",
"port_data_reference.download(local_path=\".\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Print the first five lines of the output\n",
"result_file = os.path.join(output_dir, deployment.output_file_name)\n",
"result_file = os.path.join(\"azureml\", step_run_id, \"score\", deployment.output_file_name)\n",
"with open(result_file) as f:\n",
" for x in range(5):\n",
" print(next(f))"
Expand Down

0 comments on commit 88ab31e

Please sign in to comment.