|
273 | 273 | " \"InitialVariantWeight\": 1,\n",
|
274 | 274 | " }\n",
|
275 | 275 | " ],\n",
|
276 |
| - " ShadowProductionVariants=[ # Type: Array of ProductionVariant (https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ProductionVariant.html) objects\n", |
| 276 | + " ShadowProductionVariants=[\n", |
277 | 277 | " {\n",
|
278 | 278 | " \"VariantName\": shadow_variant_name,\n",
|
279 | 279 | " \"ModelName\": model_name2,\n",
|
280 |
| - " \"InitialInstanceCount\": 3,\n", |
281 |
| - " \"InitialVariantWeight\": 0.5,\n", |
282 | 280 | " \"InstanceType\": \"ml.m5.xlarge\",\n",
|
| 281 | + " \"InitialInstanceCount\": 1,\n", |
| 282 | + " \"InitialVariantWeight\": 0.5,\n", |
283 | 283 | " }\n",
|
284 | 284 | " ],\n",
|
285 | 285 | ")\n",
|
|
536 | 536 | "tags": []
|
537 | 537 | },
|
538 | 538 | "source": [
|
539 |
| - "Finally, let us review the 4xx and 5xx returned by the model. " |
| 539 | + "Finally, let us review the 4xx, 5xx and total model errors returned by the model serving container. " |
540 | 540 | ]
|
541 | 541 | },
|
542 | 542 | {
|
|
546 | 546 | "outputs": [],
|
547 | 547 | "source": [
|
548 | 548 | "Invocation4xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation4XXErrors\", \"Sum\")\n",
|
549 |
| - "Invocation5xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation5XXErrors\", \"Sum\")" |
| 549 | + "Invocation5xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation5XXErrors\", \"Sum\")\n", |
| 550 | + "Invocation5xxErrors = plot_endpoint_invocation_metrics(\n", |
| 551 | + " endpoint_name, \"InvocationModelErrors\", \"Sum\"\n", |
| 552 | + ")" |
550 | 553 | ]
|
551 | 554 | },
|
552 | 555 | {
|
|
557 | 560 | "source": [
|
558 | 561 | "We can consider promoting the shadow model if we do not see any differences in 4xx and 5xx errors between the production shadow variants. \n",
|
559 | 562 | "\n",
|
560 |
| - "To promote the shadow model to production, create a new endpoint configuration with current ShadowProductionVariant as the new ProductionVariant and removing the ShadowProductionVariant. This will remove the current ProductionVariant and promote the shadow variant to become the new production variant. As always, all SageMaker updates are orchestrated as blue/green deployments under the hood and there is no loss of availability while performing the update. Optionally, you can leverage [Deployment Guardrails](https://docs.aws.amazon.com/sagemaker/latest/dg/deployment-guardrails.html) if you want to use linear and canary traffic shifting modes and auto rollbacks during your update\n", |
561 |
| - "\n", |
| 563 | + "To promote the shadow model to production, create a new endpoint configuration with current ShadowProductionVariant as the new ProductionVariant and removing the ShadowProductionVariant. This will remove the current ProductionVariant and promote the shadow variant to become the new production variant. As always, all SageMaker updates are orchestrated as blue/green deployments under the hood and there is no loss of availability while performing the update. Optionally, you can leverage [Deployment Guardrails](https://docs.aws.amazon.com/sagemaker/latest/dg/deployment-guardrails.html) if you want to use all-at-once traffic shifting and auto rollbacks during your update." |
| 564 | + ] |
| 565 | + }, |
| 566 | + { |
| 567 | + "cell_type": "code", |
| 568 | + "execution_count": null, |
| 569 | + "metadata": {}, |
| 570 | + "outputs": [], |
| 571 | + "source": [ |
| 572 | + "promote_ep_config_name = f\"PromoteShadow-EpConfig-{datetime.now():%Y-%m-%d-%H-%M-%S}\"\n", |
562 | 573 | "\n",
|
563 |
| - "If you do not want to create multiple endpoint configurations and want SageMaker to manage the end to end workflow of creating, managing, and acting on the results of the shadow tests, consider using the SageMaker Inference Experiement APIs/Console experience. As stated earlier, they enable you to setup shadow tests for a predefined duration of time, monitor the progress through a live dashboard, presents clean up options upon completion, and act on the results. To get started, please navigate to the 'Shadow Tests' section of the SageMaker Inference console. " |
| 574 | + "create_endpoint_config_response = sm.create_endpoint_config(\n", |
| 575 | + " EndpointConfigName=promote_ep_config_name,\n", |
| 576 | + " ProductionVariants=[\n", |
| 577 | + " {\n", |
| 578 | + " \"VariantName\": shadow_variant_name,\n", |
| 579 | + " \"ModelName\": model_name2,\n", |
| 580 | + " \"InstanceType\": \"ml.m5.xlarge\",\n", |
| 581 | + " \"InitialInstanceCount\": 2,\n", |
| 582 | + " \"InitialVariantWeight\": 1.0,\n", |
| 583 | + " }\n", |
| 584 | + " ],\n", |
| 585 | + ")\n", |
| 586 | + "print(f\"Created EndpointConfig: {create_endpoint_config_response['EndpointConfigArn']}\")" |
564 | 587 | ]
|
565 | 588 | },
|
566 | 589 | {
|
|
569 | 592 | "metadata": {},
|
570 | 593 | "outputs": [],
|
571 | 594 | "source": [
|
572 |
| - "plot_endpoint_invocation_metrics(endpoint_name, \"CPUUtilization\", \"Average\")" |
| 595 | + "update_endpoint_api_response = sm.update_endpoint(\n", |
| 596 | + " EndpointName=endpoint_name,\n", |
| 597 | + " EndpointConfigName=promote_ep_config_name,\n", |
| 598 | + ")\n", |
| 599 | + "\n", |
| 600 | + "wait_for_endpoint_in_service(endpoint_name)\n", |
| 601 | + "\n", |
| 602 | + "sm.describe_endpoint(EndpointName=endpoint_name)" |
| 603 | + ] |
| 604 | + }, |
| 605 | + { |
| 606 | + "cell_type": "markdown", |
| 607 | + "metadata": {}, |
| 608 | + "source": [ |
| 609 | + "If you do not want to create multiple endpoint configurations and want SageMaker to manage the end to end workflow of creating, managing, and acting on the results of the shadow tests, consider using the SageMaker Inference Experiement APIs/Console experience. As stated earlier, they enable you to setup shadow tests for a predefined duration of time, monitor the progress through a live dashboard, presents clean up options upon completion, and act on the results. To get started, please navigate to the 'Shadow Tests' section of the SageMaker Inference console. " |
573 | 610 | ]
|
574 | 611 | },
|
575 | 612 | {
|
|
593 | 630 | "outputs": [],
|
594 | 631 | "source": [
|
595 | 632 | "sm.delete_endpoint(EndpointName=endpoint_name)\n",
|
596 |
| - "sm.delete_endpoint_config(EndpointConfigName=ep_config_name)" |
| 633 | + "sm.delete_endpoint_config(EndpointConfigName=ep_config_name)\n", |
| 634 | + "sm.delete_endpoint_config(EndpointConfigName=promote_ep_config_name)\n", |
| 635 | + "sm.delete_model(ModelName=model_name)\n", |
| 636 | + "sm.delete_model(ModelName=model_name2)" |
597 | 637 | ]
|
598 | 638 | }
|
599 | 639 | ],
|
|
0 commit comments