From d902c5ae7b9d08c7bbc93b631748c252d732dc3e Mon Sep 17 00:00:00 2001 From: Riti Sharma Date: Thu, 20 Apr 2023 09:29:44 -0700 Subject: [PATCH 1/3] fix od batch scoring notebook --- ...ction-batch-scoring-non-mlflow-model.ipynb | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb index efff9eb59b..ff7ef4a20a 100644 --- a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb +++ b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb @@ -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", ")" ] @@ -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)" ] @@ -1097,13 +1097,38 @@ "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('Pipeline Run ID: {} Step Run ID: {}, Step Run Node ID: {}'.format(pipeline_run.id, step_run_id, node_id))\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))" From 68130899a226f1963d2a79badef791b733bcd028 Mon Sep 17 00:00:00 2001 From: Riti Sharma Date: Thu, 20 Apr 2023 09:37:06 -0700 Subject: [PATCH 2/3] format file --- ...etection-batch-scoring-non-mlflow-model.ipynb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb index ff7ef4a20a..f51838c665 100644 --- a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb +++ b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb @@ -1103,7 +1103,7 @@ "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", + " workspace_name=ml_client.workspace_name,\n", ")\n", "\n", "# Get the Pipeline Run\n", @@ -1111,13 +1111,17 @@ "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('Pipeline Run ID: {} Step Run ID: {}, Step Run Node ID: {}'.format(pipeline_run.id, step_run_id, node_id))\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 = step_run.get_output_data(\"score\")\n", "port_data_reference.download(local_path=\".\")" ] }, @@ -1128,7 +1132,7 @@ "outputs": [], "source": [ "# Print the first five lines of the output\n", - "result_file = os.path.join('azureml', step_run_id, 'score', 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))" From 46d3e206ec4cb3a95f5fdd6976b431f25cced1c1 Mon Sep 17 00:00:00 2001 From: Riti Sharma Date: Fri, 21 Apr 2023 10:23:44 -0700 Subject: [PATCH 3/3] update broken path --- .../image-object-detection-batch-scoring-non-mlflow-model.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb index f51838c665..9b75ad1275 100644 --- a/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb +++ b/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items-batch-scoring/image-object-detection-batch-scoring-non-mlflow-model.ipynb @@ -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)" ] }, {