diff --git a/program/cohort.ipynb b/program/cohort.ipynb
index 91a0293..77e694a 100644
--- a/program/cohort.ipynb
+++ b/program/cohort.ipynb
@@ -33732,7 +33732,7 @@
},
{
"cell_type": "code",
- "execution_count": 429,
+ "execution_count": 494,
"id": "f70bcd33-b499-4e2b-953e-94d1ed96c10a",
"metadata": {
"tags": [
@@ -33740,13 +33740,34 @@
]
},
"outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "INFO:sagemaker.image_uris:image_uri is not presented, retrieving image_uri based on instance_type, framework etc.\n",
+ "INFO:sagemaker.processing:Uploaded None to s3://mlschool/session9-pipeline/code/c90fe2477ad62c58fbc0c004cc5ab07f/sourcedir.tar.gz\n",
+ "INFO:sagemaker.processing:runproc.sh uploaded to s3://mlschool/session9-pipeline/code/f3b7867d7495763812a03744135acb08/runproc.sh\n",
+ "/Users/svpino/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/workflow/pipeline_context.py:332: UserWarning: Running within a PipelineSession, there will be No Wait, No Logs, and No Job being started.\n",
+ " warnings.warn(\n",
+ "INFO:sagemaker.image_uris:image_uri is not presented, retrieving image_uri based on instance_type, framework etc.\n",
+ "INFO:sagemaker.processing:Uploaded None to s3://mlschool/session9-pipeline/code/c90fe2477ad62c58fbc0c004cc5ab07f/sourcedir.tar.gz\n",
+ "INFO:sagemaker.processing:runproc.sh uploaded to s3://mlschool/session9-pipeline/code/f3b7867d7495763812a03744135acb08/runproc.sh\n"
+ ]
+ },
{
"data": {
"text/plain": [
- "{'PipelineArn': 'session9-pipeline'}"
+ "{'PipelineArn': 'arn:aws:sagemaker:us-east-1:325223348818:pipeline/session9-pipeline',\n",
+ " 'ResponseMetadata': {'RequestId': '1da54e45-294d-4d80-889d-1c94aa4cc9da',\n",
+ " 'HTTPStatusCode': 200,\n",
+ " 'HTTPHeaders': {'x-amzn-requestid': '1da54e45-294d-4d80-889d-1c94aa4cc9da',\n",
+ " 'content-type': 'application/x-amz-json-1.1',\n",
+ " 'content-length': '85',\n",
+ " 'date': 'Tue, 26 Mar 2024 19:30:16 GMT'},\n",
+ " 'RetryAttempts': 0}}"
]
},
- "execution_count": 429,
+ "execution_count": 494,
"metadata": {},
"output_type": "execute_result"
}
@@ -33779,7 +33800,7 @@
"\n",
"
\n",
"\n",
- "Keep in mind that, while good for development and testing, this approach is not the best approach for production systems.\n"
+ "Keep in mind that, while good for development and testing, this is not the best approach for production systems.\n"
]
},
{
@@ -33794,7 +33815,7 @@
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 496,
"id": "a67726d7",
"metadata": {},
"outputs": [
@@ -33802,14 +33823,14 @@
"data": {
"text/plain": [
"{'ModelPackageGroupName': 'basic-penguins',\n",
- " 'ModelPackageVersion': 2,\n",
- " 'ModelPackageArn': 'arn:aws:sagemaker:us-east-1:325223348818:model-package/basic-penguins/2',\n",
- " 'CreationTime': datetime.datetime(2024, 3, 16, 9, 59, 29, 161000, tzinfo=tzlocal()),\n",
+ " 'ModelPackageVersion': 4,\n",
+ " 'ModelPackageArn': 'arn:aws:sagemaker:us-east-1:325223348818:model-package/basic-penguins/4',\n",
+ " 'CreationTime': datetime.datetime(2024, 3, 26, 15, 43, 59, 510000, tzinfo=tzlocal()),\n",
" 'ModelPackageStatus': 'Completed',\n",
" 'ModelApprovalStatus': 'Approved'}"
]
},
- "execution_count": 64,
+ "execution_count": 496,
"metadata": {},
"output_type": "execute_result"
}
@@ -33838,14 +33859,20 @@
"source": [
"### Step 2 - Downloading the Model\n",
"\n",
- "Let's now download the model assets from the location specified in the Model Registry to your local environment.\n",
- "\n",
+ "Let's now download the model assets from the location specified in the Model Registry to your local environment.\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e2891178",
+ "metadata": {},
+ "source": [
"We will store this model in a folder called `serving`:\n"
]
},
{
"cell_type": "code",
- "execution_count": 65,
+ "execution_count": 497,
"id": "f2e94adc",
"metadata": {},
"outputs": [],
@@ -33863,7 +33890,7 @@
},
{
"cell_type": "code",
- "execution_count": 66,
+ "execution_count": 498,
"id": "bd12fbe9",
"metadata": {},
"outputs": [],
@@ -33893,7 +33920,7 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 499,
"id": "c79a0e74",
"metadata": {
"tags": [
@@ -33905,14 +33932,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Overwriting code/serving/app.py\n"
+ "Writing code/serving/app.py\n"
]
}
],
"source": [
"%%writefile {CODE_FOLDER}/serving/app.py\n",
- "#| filename: app.py\n",
- "#| code-line-numbers: true\n",
+ "# | filename: app.py\n",
+ "# | code-line-numbers: true\n",
"\n",
"import tarfile\n",
"import tempfile\n",
@@ -33943,10 +33970,7 @@
" with tarfile.open(MODEL_PATH / \"model.tar.gz\") as tar:\n",
" tar.extractall(path=directory)\n",
"\n",
- " Model.model = keras.models.load_model(\n",
- " Path(directory) / \"001\"\n",
- " )\n",
- "\n",
+ " Model.model = keras.models.load_model(Path(directory) / \"001\")\n",
"\n",
" def predict(self, data):\n",
" \"\"\"\n",
@@ -33972,10 +33996,7 @@
" prediction = int(np.argmax(predictions[0], axis=-1))\n",
" confidence = float(predictions[0][prediction])\n",
"\n",
- " return jsonify({\n",
- " \"prediction\": prediction, \n",
- " \"confidence\": confidence\n",
- " })\n"
+ " return jsonify({\"prediction\": prediction, \"confidence\": confidence})"
]
},
{
@@ -33985,9 +34006,7 @@
"source": [
"### Step 4 - Running the Flask Application\n",
"\n",
- "We can now run the Flask application to serve the model from a terminal or directly from this notebook.\n",
- "\n",
- "To run the server from the terminal, use the following command:\n",
+ "We can now run the Flask application to serve the model from a terminal using the following command:\n",
"\n",
"```bash\n",
"$ flask --app program/code/serving/app.py --debug run --host=0.0.0.0 --port=4242\n",
@@ -38836,7 +38855,7 @@
},
{
"cell_type": "code",
- "execution_count": 430,
+ "execution_count": 495,
"id": "59d1e634",
"metadata": {
"tags": [
@@ -38845,32 +38864,14 @@
},
"outputs": [
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "INFO:sagemaker.processing:Uploaded None to s3://mlschool/session9-pipeline/code/e29b54bb3fdd20910fddd04762820c7e/sourcedir.tar.gz\n",
- "INFO:sagemaker.processing:runproc.sh uploaded to s3://mlschool/session9-pipeline/code/f3b7867d7495763812a03744135acb08/runproc.sh\n",
- "/Users/svpino/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/workflow/pipeline_context.py:332: UserWarning: Running within a PipelineSession, there will be No Wait, No Logs, and No Job being started.\n",
- " warnings.warn(\n",
- "WARNING:sagemaker.workflow._utils:Popping out 'CertifyForMarketplace' from the pipeline definition since it will be overridden in pipeline execution time.\n"
- ]
- },
- {
- "ename": "ClientError",
- "evalue": "An error occurred (ValidationException) when calling the start_pipeline_execution operation: Step type RegisterModel is not supported in local mode.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mClientError\u001b[0m Traceback (most recent call last)",
- "Cell \u001b[0;32mIn[430], line 6\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# %%script false --no-raise-error\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# | eval: false\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# | code: true\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# | output: false\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m \u001b[43msession9_pipeline\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/workflow/pipeline.py:372\u001b[0m, in \u001b[0;36mPipeline.start\u001b[0;34m(self, parameters, execution_display_name, execution_description, parallelism_config, selective_execution_config)\u001b[0m\n\u001b[1;32m 370\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msagemaker_session\u001b[38;5;241m.\u001b[39mlocal_mode:\n\u001b[1;32m 371\u001b[0m update_args(kwargs, PipelineParameters\u001b[38;5;241m=\u001b[39mparameters)\n\u001b[0;32m--> 372\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msagemaker_session\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msagemaker_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart_pipeline_execution\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 373\u001b[0m update_args(kwargs, PipelineParameters\u001b[38;5;241m=\u001b[39mformat_start_parameters(parameters))\n\u001b[1;32m 375\u001b[0m \u001b[38;5;66;03m# retry on AccessDeniedException to cover case of tag propagation delay\u001b[39;00m\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/local/local_session.py:535\u001b[0m, in \u001b[0;36mLocalSagemakerClient.start_pipeline_execution\u001b[0;34m(self, PipelineName, **kwargs)\u001b[0m\n\u001b[1;32m 528\u001b[0m error_response \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 529\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mError\u001b[39m\u001b[38;5;124m\"\u001b[39m: {\n\u001b[1;32m 530\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCode\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mResourceNotFound\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 531\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMessage\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPipeline \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m does not exist\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(PipelineName),\n\u001b[1;32m 532\u001b[0m }\n\u001b[1;32m 533\u001b[0m }\n\u001b[1;32m 534\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ClientError(error_response, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstart_pipeline_execution\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 535\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mLocalSagemakerClient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_pipelines\u001b[49m\u001b[43m[\u001b[49m\u001b[43mPipelineName\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/local/entities.py:678\u001b[0m, in \u001b[0;36m_LocalPipeline.start\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msagemaker\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mlocal\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpipeline\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m LocalPipelineExecutor\n\u001b[1;32m 677\u001b[0m execution_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(uuid4())\n\u001b[0;32m--> 678\u001b[0m execution \u001b[38;5;241m=\u001b[39m \u001b[43m_LocalPipelineExecution\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 679\u001b[0m \u001b[43m \u001b[49m\u001b[43mexecution_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexecution_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 680\u001b[0m \u001b[43m \u001b[49m\u001b[43mpipeline\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpipeline\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 681\u001b[0m \u001b[43m \u001b[49m\u001b[43mlocal_session\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlocal_session\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 682\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 683\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 685\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_executions[execution_id] \u001b[38;5;241m=\u001b[39m execution\n\u001b[1;32m 686\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\n\u001b[1;32m 687\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mStarting execution for pipeline \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m. Execution ID is \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 688\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpipeline\u001b[38;5;241m.\u001b[39mname,\n\u001b[1;32m 689\u001b[0m execution_id,\n\u001b[1;32m 690\u001b[0m )\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/local/entities.py:722\u001b[0m, in \u001b[0;36m_LocalPipelineExecution.__init__\u001b[0;34m(self, execution_id, pipeline, PipelineParameters, PipelineExecutionDescription, PipelineExecutionDisplayName, local_session)\u001b[0m\n\u001b[1;32m 720\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstep_execution \u001b[38;5;241m=\u001b[39m {}\n\u001b[1;32m 721\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpipeline_dag \u001b[38;5;241m=\u001b[39m PipelineGraph\u001b[38;5;241m.\u001b[39mfrom_pipeline(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpipeline)\n\u001b[0;32m--> 722\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_initialize_step_execution\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpipeline_dag\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep_map\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalues\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 723\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpipeline_parameters \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_initialize_and_validate_parameters(PipelineParameters)\n\u001b[1;32m 724\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_blocked_steps \u001b[38;5;241m=\u001b[39m {}\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/local/entities.py:828\u001b[0m, in \u001b[0;36m_LocalPipelineExecution._initialize_step_execution\u001b[0;34m(self, steps)\u001b[0m\n\u001b[1;32m 824\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstep_execution[step\u001b[38;5;241m.\u001b[39mname] \u001b[38;5;241m=\u001b[39m _LocalPipelineExecutionStep(\n\u001b[1;32m 825\u001b[0m step\u001b[38;5;241m.\u001b[39mname, step\u001b[38;5;241m.\u001b[39mstep_type, step\u001b[38;5;241m.\u001b[39mdescription, step\u001b[38;5;241m.\u001b[39mdisplay_name\n\u001b[1;32m 826\u001b[0m )\n\u001b[1;32m 827\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m step\u001b[38;5;241m.\u001b[39mstep_type \u001b[38;5;241m==\u001b[39m StepTypeEnum\u001b[38;5;241m.\u001b[39mCONDITION:\n\u001b[0;32m--> 828\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_initialize_step_execution\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstep\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mif_steps\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mstep\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43melse_steps\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/dev/ml.school/.venv/lib/python3.10/site-packages/sagemaker/local/entities.py:823\u001b[0m, in \u001b[0;36m_LocalPipelineExecution._initialize_step_execution\u001b[0;34m(self, steps)\u001b[0m\n\u001b[1;32m 819\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m step\u001b[38;5;241m.\u001b[39mstep_type \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m supported_steps_types:\n\u001b[1;32m 820\u001b[0m error_msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_construct_validation_exception_message(\n\u001b[1;32m 821\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mStep type \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m is not supported in local mode.\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(step\u001b[38;5;241m.\u001b[39mstep_type\u001b[38;5;241m.\u001b[39mvalue)\n\u001b[1;32m 822\u001b[0m )\n\u001b[0;32m--> 823\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ClientError(error_msg, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstart_pipeline_execution\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 824\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstep_execution[step\u001b[38;5;241m.\u001b[39mname] \u001b[38;5;241m=\u001b[39m _LocalPipelineExecutionStep(\n\u001b[1;32m 825\u001b[0m step\u001b[38;5;241m.\u001b[39mname, step\u001b[38;5;241m.\u001b[39mstep_type, step\u001b[38;5;241m.\u001b[39mdescription, step\u001b[38;5;241m.\u001b[39mdisplay_name\n\u001b[1;32m 826\u001b[0m )\n\u001b[1;32m 827\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m step\u001b[38;5;241m.\u001b[39mstep_type \u001b[38;5;241m==\u001b[39m StepTypeEnum\u001b[38;5;241m.\u001b[39mCONDITION:\n",
- "\u001b[0;31mClientError\u001b[0m: An error occurred (ValidationException) when calling the start_pipeline_execution operation: Step type RegisterModel is not supported in local mode."
- ]
+ "data": {
+ "text/plain": [
+ "_PipelineExecution(arn='arn:aws:sagemaker:us-east-1:325223348818:pipeline/session9-pipeline/execution/cpqzzpyrpzy2', sagemaker_session=)"
+ ]
+ },
+ "execution_count": 495,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [