diff --git a/sagemaker-inference-recommender/huggingface-inference-recommender/huggingface-inference-recommender.ipynb b/sagemaker-inference-recommender/huggingface-inference-recommender/huggingface-inference-recommender.ipynb index cc7386cdbd..ef3ca53449 100644 --- a/sagemaker-inference-recommender/huggingface-inference-recommender/huggingface-inference-recommender.ipynb +++ b/sagemaker-inference-recommender/huggingface-inference-recommender/huggingface-inference-recommender.ipynb @@ -513,6 +513,79 @@ "print(model_package_version_response)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Alternative Option: ContainerConfig\n", + "\n", + "If you are missing mandatory fields to create an inference recommender job in your model package version like so (this `create_model_package` is missing `Domain`, `Task`, and `SamplePayloadUrl`):\n", + "\n", + "```\n", + "client.create_model_package(\n", + " ModelPackageGroupName=str(model_package_group_name),\n", + " ModelPackageDescription=\"HuggingFace PyTorch Inference Recommender Demo\",\n", + " InferenceSpecification={\n", + " \"Containers\": [\n", + " {\n", + " \"ContainerHostname\": \"huggingface-pytorch\",\n", + " \"Image\": inference_image,\n", + " \"ModelDataUrl\": model_url,\n", + " \"Framework\": ml_framework,\n", + " \"NearestModelName\": model,\n", + " \"Environment\": {\n", + " \"SAGEMAKER_CONTAINER_LOG_LEVEL\": \"20\",\n", + " \"SAGEMAKER_PROGRAM\": \"inference.py\",\n", + " \"SAGEMAKER_REGION\": region,\n", + " \"SAGEMAKER_SUBMIT_DIRECTORY\": model_url,\n", + " },\n", + " },\n", + " ],\n", + " \"SupportedRealtimeInferenceInstanceTypes\": [\n", + " \"ml.c5.large\",\n", + " \"ml.c5.xlarge\",\n", + " \"ml.c5.2xlarge\",\n", + " \"ml.m5.xlarge\",\n", + " \"ml.m5.2xlarge\",\n", + " ],\n", + " \"SupportedContentTypes\": [\"text/csv\"],\n", + " \"SupportedResponseMIMETypes\": [\"text/csv\"],\n", + " },\n", + ")\n", + "```\n", + "\n", + "You may define the fields `Domain`, `Task`, and `SamplePayloadUrl` in the optional field `ContainerConfig` like so:\n", + "\n", + "```\n", + "payload_config = {\n", + " \"SamplePayloadUrl\": sample_payload_url,\n", + "}\n", + "\n", + "container_config = {\n", + " \"Domain\": ml_domain,\n", + " \"Task\": ml_task,\n", + " \"PayloadConfig\": payload_config,\n", + "}\n", + "```\n", + "\n", + "And then provide it directly within `create_inference_recommendations_job()` API like so:\n", + "\n", + "```\n", + "default_response = client.create_inference_recommendations_job(\n", + " JobName=str(default_job),\n", + " JobDescription=\"\",\n", + " JobType=\"Default\",\n", + " RoleArn=role,\n", + " InputConfig={\n", + " \"ModelPackageVersionArn\": model_package_arn,\n", + " \"ContainerConfig\": container_config\n", + " },\n", + ")\n", + "```\n", + "\n", + "For more information on what else can be provided via `ContainerConfig` please refer to the `CreateInferenceRecommendationsJob` doc here: [CreateInferenceRecommendationsJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateInferenceRecommendationsJob.html)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -621,7 +694,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)" ] }, diff --git a/sagemaker-inference-recommender/inference-recommender.ipynb b/sagemaker-inference-recommender/inference-recommender.ipynb index 95eb54c7e8..f493ed319c 100644 --- a/sagemaker-inference-recommender/inference-recommender.ipynb +++ b/sagemaker-inference-recommender/inference-recommender.ipynb @@ -607,6 +607,54 @@ "sm_client.describe_model_package(ModelPackageName=model_package_arn)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Alternative Option: ContainerConfig\n", + "\n", + "If you are missing mandatory fields to create an inference recommender job in your model package version like so (this `create_model_package_input_dict` is missing `Domain`, `Task`, and `SamplePayloadUrl`):\n", + "\n", + "```\n", + "create_model_package_input_dict = {\n", + " \"ModelPackageGroupName\": model_package_group_name,\n", + " \"ModelPackageDescription\": model_package_description,\n", + " \"ModelApprovalStatus\": model_approval_status,\n", + "}\n", + "```\n", + "\n", + "You may define the fields `Domain`, `Task`, and `SamplePayloadUrl` in the optional field `ContainerConfig` like so:\n", + "\n", + "```\n", + "payload_config = {\n", + " \"SamplePayloadUrl\": sample_payload_url,\n", + "}\n", + "\n", + "container_config = {\n", + " \"Domain\": ml_domain.upper(),\n", + " \"Task\": ml_task.upper(),\n", + " \"PayloadConfig\": payload_config,\n", + "}\n", + "```\n", + "\n", + "And then provide it directly within `create_inference_recommendations_job()` API like so:\n", + "\n", + "```\n", + "default_response = client.create_inference_recommendations_job(\n", + " JobName=str(default_job),\n", + " JobDescription=\"\",\n", + " JobType=\"Default\",\n", + " RoleArn=role,\n", + " InputConfig={\n", + " \"ModelPackageVersionArn\": model_package_arn,\n", + " \"ContainerConfig\": container_config\n", + " },\n", + ")\n", + "```\n", + "\n", + "For more information on what else can be provided via `ContainerConfig` please refer to the `CreateInferenceRecommendationsJob` doc here: [CreateInferenceRecommendationsJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateInferenceRecommendationsJob.html)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -709,7 +757,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ] @@ -828,7 +877,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ] diff --git a/sagemaker-inference-recommender/sklearn-inference-recommender/sklearn-inference-recommender.ipynb b/sagemaker-inference-recommender/sklearn-inference-recommender/sklearn-inference-recommender.ipynb index c0704e9d94..bda343d8ca 100644 --- a/sagemaker-inference-recommender/sklearn-inference-recommender/sklearn-inference-recommender.ipynb +++ b/sagemaker-inference-recommender/sklearn-inference-recommender/sklearn-inference-recommender.ipynb @@ -40,8 +40,7 @@ "execution_count": null, "metadata": { "collapsed": false, - "jupyter": { - }, + "jupyter": {}, "pycharm": { "name": "#%%\n" } @@ -56,8 +55,7 @@ "execution_count": null, "metadata": { "collapsed": false, - "jupyter": { - }, + "jupyter": {}, "pycharm": { "name": "#%%\n" } @@ -459,6 +457,79 @@ "print(model_package_version_response)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Alternative Option: ContainerConfig\n", + "\n", + "If you are missing mandatory fields to create an inference recommender job in your model package version like so (this `create_model_package` is missing `Domain`, `Task`, and `SamplePayloadUrl`):\n", + "\n", + "```\n", + "client.create_model_package(\n", + " ModelPackageGroupName=str(model_package_group_name),\n", + " ModelPackageDescription=\"scikit-learn Inference Recommender Demo\",\n", + " InferenceSpecification={\n", + " \"Containers\": [\n", + " {\n", + " \"ContainerHostname\": \"scikit-learn\",\n", + " \"Image\": inference_image,\n", + " \"ModelDataUrl\": model_url,\n", + " \"Framework\": ml_framework,\n", + " \"NearestModelName\": model,\n", + " \"Environment\": {\n", + " \"SAGEMAKER_CONTAINER_LOG_LEVEL\": \"20\",\n", + " \"SAGEMAKER_PROGRAM\": sagemaker_program,\n", + " \"SAGEMAKER_REGION\": region,\n", + " \"SAGEMAKER_SUBMIT_DIRECTORY\": sourcedir_url,\n", + " },\n", + " },\n", + " ],\n", + " \"SupportedRealtimeInferenceInstanceTypes\": [\n", + " \"ml.c5.large\",\n", + " \"ml.c5.xlarge\",\n", + " \"ml.c5.2xlarge\",\n", + " \"ml.m5.xlarge\",\n", + " \"ml.m5.2xlarge\",\n", + " ],\n", + " \"SupportedContentTypes\": [\"text/csv\"],\n", + " \"SupportedResponseMIMETypes\": [\"text/csv\"],\n", + " },\n", + ")\n", + "```\n", + "\n", + "You may define the fields `Domain`, `Task`, and `SamplePayloadUrl` in the optional field `ContainerConfig` like so:\n", + "\n", + "```\n", + "payload_config = {\n", + " \"SamplePayloadUrl\": sample_payload_url,\n", + "}\n", + "\n", + "container_config = {\n", + " \"Domain\": ml_domain,\n", + " \"Task\": ml_task,\n", + " \"PayloadConfig\": payload_config,\n", + "}\n", + "```\n", + "\n", + "And then provide it directly within `create_inference_recommendations_job()` API like so:\n", + "\n", + "```\n", + "default_response = client.create_inference_recommendations_job(\n", + " JobName=str(default_job),\n", + " JobDescription=\"\",\n", + " JobType=\"Default\",\n", + " RoleArn=role,\n", + " InputConfig={\n", + " \"ModelPackageVersionArn\": model_package_arn,\n", + " \"ContainerConfig\": container_config\n", + " },\n", + ")\n", + "```\n", + "\n", + "For more information on what else can be provided via `ContainerConfig` please refer to the `CreateInferenceRecommendationsJob` doc here: [CreateInferenceRecommendationsJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateInferenceRecommendationsJob.html)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -567,7 +638,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)" ] }, @@ -717,7 +789,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ] diff --git a/sagemaker-inference-recommender/tensorflow-cloudwatch/tf-cloudwatch-inference-recommender.ipynb b/sagemaker-inference-recommender/tensorflow-cloudwatch/tf-cloudwatch-inference-recommender.ipynb index eed4f4db0c..ec97f091a0 100644 --- a/sagemaker-inference-recommender/tensorflow-cloudwatch/tf-cloudwatch-inference-recommender.ipynb +++ b/sagemaker-inference-recommender/tensorflow-cloudwatch/tf-cloudwatch-inference-recommender.ipynb @@ -484,6 +484,54 @@ "print(\"ModelPackage Version ARN : {}\".format(model_package_arn))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Alternative Option: ContainerConfig\n", + "\n", + "If you are missing mandatory fields to create an inference recommender job in your model package version like so (this `create_model_package_input_dict` is missing `Domain`, `Task`, and `SamplePayloadUrl`):\n", + "\n", + "```\n", + "create_model_package_input_dict = {\n", + " \"ModelPackageGroupName\": model_package_group_name,\n", + " \"ModelPackageDescription\": model_package_description,\n", + " \"ModelApprovalStatus\": model_approval_status,\n", + "}\n", + "```\n", + "\n", + "You may define the fields `Domain`, `Task`, and `SamplePayloadUrl` in the optional field `ContainerConfig` like so:\n", + "\n", + "```\n", + "payload_config = {\n", + " \"SamplePayloadUrl\": sample_payload_url,\n", + "}\n", + "\n", + "container_config = {\n", + " \"Domain\": ml_domain.upper(),\n", + " \"Task\": ml_task.upper(),\n", + " \"PayloadConfig\": payload_config,\n", + "}\n", + "```\n", + "\n", + "And then provide it directly within `create_inference_recommendations_job()` API like so:\n", + "\n", + "```\n", + "default_response = client.create_inference_recommendations_job(\n", + " JobName=str(default_job),\n", + " JobDescription=\"\",\n", + " JobType=\"Default\",\n", + " RoleArn=role,\n", + " InputConfig={\n", + " \"ModelPackageVersionArn\": model_package_arn,\n", + " \"ContainerConfig\": container_config\n", + " },\n", + ")\n", + "```\n", + "\n", + "For more information on what else can be provided via `ContainerConfig` please refer to the `CreateInferenceRecommendationsJob` doc here: [CreateInferenceRecommendationsJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateInferenceRecommendationsJob.html)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -583,7 +631,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ] @@ -778,7 +827,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ] diff --git a/sagemaker-inference-recommender/xgboost/xgboost-inference-recommender.ipynb b/sagemaker-inference-recommender/xgboost/xgboost-inference-recommender.ipynb index 3ae7e16924..a0dfe49986 100644 --- a/sagemaker-inference-recommender/xgboost/xgboost-inference-recommender.ipynb +++ b/sagemaker-inference-recommender/xgboost/xgboost-inference-recommender.ipynb @@ -509,6 +509,54 @@ "print(\"ModelPackage Version ARN : {}\".format(model_package_arn))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Alternative Option: ContainerConfig\n", + "\n", + "If you are missing mandatory fields to create an inference recommender job in your model package version like so (this `create_model_package_input_dict` is missing `Domain`, `Task`, and `SamplePayloadUrl`):\n", + "\n", + "```\n", + "create_model_package_input_dict = {\n", + " \"ModelPackageGroupName\": model_package_group_name,\n", + " \"ModelPackageDescription\": model_package_description,\n", + " \"ModelApprovalStatus\": model_approval_status,\n", + "}\n", + "```\n", + "\n", + "You may define the fields `Domain`, `Task`, and `SamplePayloadUrl` in the optional field `ContainerConfig` like so:\n", + "\n", + "```\n", + "payload_config = {\n", + " \"SamplePayloadUrl\": sample_payload_url,\n", + "}\n", + "\n", + "container_config = {\n", + " \"Domain\": ml_domain.upper(),\n", + " \"Task\": ml_task.upper(),\n", + " \"PayloadConfig\": payload_config,\n", + "}\n", + "```\n", + "\n", + "And then provide it directly within `create_inference_recommendations_job()` API like so:\n", + "\n", + "```\n", + "default_response = client.create_inference_recommendations_job(\n", + " JobName=str(default_job),\n", + " JobDescription=\"\",\n", + " JobType=\"Default\",\n", + " RoleArn=role,\n", + " InputConfig={\n", + " \"ModelPackageVersionArn\": model_package_arn,\n", + " \"ContainerConfig\": container_config\n", + " },\n", + ")\n", + "```\n", + "\n", + "For more information on what else can be provided via `ContainerConfig` please refer to the `CreateInferenceRecommendationsJob` doc here: [CreateInferenceRecommendationsJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateInferenceRecommendationsJob.html)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -606,7 +654,8 @@ " for x in inference_recommender_job[\"InferenceRecommendations\"]\n", "]\n", "df = pd.DataFrame(data)\n", - "df.drop(\"VariantName\", inplace=True, axis=1)\n", + "dropFilter = df.filter([\"VariantName\"])\n", + "df.drop(dropFilter, inplace=True, axis=1)\n", "pd.set_option(\"max_colwidth\", 400)\n", "df.head()" ]