Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion vision/automl/edge_container_predict/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM tensorflow/serving:1.14.0
ARG TF_SERVING_IMAGE_TAG
FROM tensorflow/serving:${TF_SERVING_IMAGE_TAG}

ENV GCS_READ_CACHE_MAX_STALENESS 300
ENV GCS_STAT_CACHE_MAX_AGE 300
Expand Down
7 changes: 7 additions & 0 deletions vision/automl/edge_container_predict/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ The outputs are
```bash
sudo docker stop ${CONTAINER_NAME}
```

Note: The docker image is uploaded with the following command.

```bash
gcloud builds --project=cloud-devrel-public-resources \
submit --config cloudbuild.yaml
```
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,35 @@
def edge_container_predict_server_port():
# set up
# Pull the CPU docker.
subprocess.check_output(['docker', 'pull', CPU_DOCKER_GCS_PATH])
subprocess.check_output(
['docker', 'pull', CPU_DOCKER_GCS_PATH],
env={'DOCKER_API_VERSION': '1.38'})

# Get the sample saved model.
if not os.path.exists(MODEL_PATH):
os.mkdir(MODEL_PATH)
subprocess.check_output(
['gsutil', '-m', 'cp', SAMPLE_SAVED_MODEL, MODEL_PATH])
['gsutil', '-m', 'cp', SAMPLE_SAVED_MODEL, MODEL_PATH])

# Start the CPU docker.
subprocess.Popen(['docker', 'run', '--rm', '--name', NAME, '-v',
MODEL_PATH + ':/tmp/mounted_model/0001', '-p',
str(PORT_NUMBER) + ':8501', '-t',
CPU_DOCKER_GCS_PATH])
CPU_DOCKER_GCS_PATH],
env={'DOCKER_API_VERSION': '1.38'})
# Sleep a few seconds to wait for the container running.
time.sleep(10)

yield PORT_NUMBER

# tear down
# Stop the container.
subprocess.check_output(['docker', 'stop', NAME])
subprocess.check_output(
['docker', 'stop', NAME], env={'DOCKER_API_VERSION': '1.38'})
# Remove the docker image.
subprocess.check_output(['docker', 'rmi', CPU_DOCKER_GCS_PATH])
subprocess.check_output(
['docker', 'rmi', CPU_DOCKER_GCS_PATH],
env={'DOCKER_API_VERSION': '1.38'})


def test_edge_container_predict(capsys, edge_container_predict_server_port):
Expand Down
26 changes: 26 additions & 0 deletions vision/automl/edge_container_predict/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 3600s

steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0',
'--build-arg', 'TF_SERVING_IMAGE_TAG=1.14.0', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0-gpu',
'--build-arg', 'TF_SERVING_IMAGE_TAG=1.14.0-gpu', '.']
images:
- 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0'
- 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0-gpu'