Skip to content

Commit

Permalink
format TensorFlow Triton example
Browse files Browse the repository at this point in the history
  • Loading branch information
marckarp committed Aug 16, 2022
1 parent 74e2569 commit df09eb2
Showing 1 changed file with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
"\n",
"# use the region-specific saved model object\n",
"region = boto3.Session().region_name\n",
"saved_model = (\n",
" \"s3://sagemaker-sample-files/datasets/image/MNIST/model/tensorflow-training-2020-11-20-23-57-13-077/model.tar.gz\"\n",
" )\n",
"saved_model = \"s3://sagemaker-sample-files/datasets/image/MNIST/model/tensorflow-training-2020-11-20-23-57-13-077/model.tar.gz\"\n",
"!aws s3 cp $saved_model models/SavedModel/"
]
},
Expand All @@ -90,6 +88,7 @@
"outputs": [],
"source": [
"import sagemaker\n",
"\n",
"sm_session = sagemaker.Session()\n",
"role = sagemaker.get_execution_role()\n",
"bucket_name = sm_session.default_bucket()"
Expand All @@ -102,30 +101,29 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"account_id_map = {\n",
" 'us-east-1': '785573368785',\n",
" 'us-east-2': '007439368137',\n",
" 'us-west-1': '710691900526',\n",
" 'us-west-2': '301217895009',\n",
" 'eu-west-1': '802834080501',\n",
" 'eu-west-2': '205493899709',\n",
" 'eu-west-3': '254080097072',\n",
" 'eu-north-1': '601324751636',\n",
" 'eu-south-1': '966458181534',\n",
" 'eu-central-1': '746233611703',\n",
" 'ap-east-1': '110948597952',\n",
" 'ap-south-1': '763008648453',\n",
" 'ap-northeast-1': '941853720454',\n",
" 'ap-northeast-2': '151534178276',\n",
" 'ap-southeast-1': '324986816169',\n",
" 'ap-southeast-2': '355873309152',\n",
" 'cn-northwest-1': '474822919863',\n",
" 'cn-north-1': '472730292857',\n",
" 'sa-east-1': '756306329178',\n",
" 'ca-central-1': '464438896020',\n",
" 'me-south-1': '836785723513',\n",
" 'af-south-1': '774647643957'\n",
" \"us-east-1\": \"785573368785\",\n",
" \"us-east-2\": \"007439368137\",\n",
" \"us-west-1\": \"710691900526\",\n",
" \"us-west-2\": \"301217895009\",\n",
" \"eu-west-1\": \"802834080501\",\n",
" \"eu-west-2\": \"205493899709\",\n",
" \"eu-west-3\": \"254080097072\",\n",
" \"eu-north-1\": \"601324751636\",\n",
" \"eu-south-1\": \"966458181534\",\n",
" \"eu-central-1\": \"746233611703\",\n",
" \"ap-east-1\": \"110948597952\",\n",
" \"ap-south-1\": \"763008648453\",\n",
" \"ap-northeast-1\": \"941853720454\",\n",
" \"ap-northeast-2\": \"151534178276\",\n",
" \"ap-southeast-1\": \"324986816169\",\n",
" \"ap-southeast-2\": \"355873309152\",\n",
" \"cn-northwest-1\": \"474822919863\",\n",
" \"cn-north-1\": \"472730292857\",\n",
" \"sa-east-1\": \"756306329178\",\n",
" \"ca-central-1\": \"464438896020\",\n",
" \"me-south-1\": \"836785723513\",\n",
" \"af-south-1\": \"774647643957\",\n",
"}"
]
},
Expand All @@ -137,7 +135,7 @@
"outputs": [],
"source": [
"if region not in account_id_map.keys():\n",
" raise(\"UNSUPPORTED REGION\")"
" raise (\"UNSUPPORTED REGION\")"
]
},
{
Expand All @@ -160,7 +158,7 @@
"metadata": {},
"outputs": [],
"source": [
"!tar -xf models/SavedModel/model.tar.gz -C models/SavedModel/\n"
"!tar -xf models/SavedModel/model.tar.gz -C models/SavedModel/"
]
},
{
Expand Down Expand Up @@ -348,12 +346,12 @@
"source": [
"from sagemaker.model import Model\n",
"\n",
"tensorflow_model = Model(model_data=model_location, \n",
" role=role,\n",
" env ={\n",
" \"SAGEMAKER_TRITON_DEFAULT_MODEL_NAME\": \"MNIST\"\n",
" },\n",
" image_uri=triton_image_uri)"
"tensorflow_model = Model(\n",
" model_data=model_location,\n",
" role=role,\n",
" env={\"SAGEMAKER_TRITON_DEFAULT_MODEL_NAME\": \"MNIST\"},\n",
" image_uri=triton_image_uri,\n",
")"
]
},
{
Expand All @@ -364,9 +362,10 @@
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"date = datetime.now().strftime(\"%Y-%m-%d-%H-%m-%S\")\n",
"\n",
"endpoint_name = f\"Triton-MNIST-{date}\" "
"endpoint_name = f\"Triton-MNIST-{date}\""
]
},
{
Expand Down

0 comments on commit df09eb2

Please sign in to comment.