Skip to content

Automl edge predict test #2195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 5, 2019
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
2 changes: 1 addition & 1 deletion .kokoro/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build_file: "python-docs-samples/.kokoro/trampoline.sh"
# Use the Python worker docker image.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python@sha256:e11a459d01e5dcd3613fda35c7c94edfecfe911ed79c078580ff59de300b1938"
value: "gcr.io/cloud-devrel-kokoro-resources/python@sha256:9f83a3711eef244a4d45ac25028e200c87c4d4060d445438683a1ed4d3f093b6"
}

# Specify project ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

# The absolute path of the current file. This will locate the model_path when
# run docker containers.
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
ROOT_DIR = os.environ.get('KOKORO_ROOT', os.path.abspath(os.path.dirname(__file__)))
MODEL_PATH = os.path.join(ROOT_DIR, 'model_path')

IMAGE_FILE_PATH = os.path.join(os.path.dirname(__file__), 'test.jpg')
# The cpu docker gcs path is from 'Edge container tutorial'.
DOCKER_GCS_DIR = 'gcr.io/automl-vision-ondevice/'
CPU_DOCKER_GCS_PATH = DOCKER_GCS_DIR + 'gcloud-container-1.12.0:latest'
CPU_DOCKER_GCS_PATH = 'gcr.io/automl-vision-ondevice/gcloud-container-1.12.0:latest'
# The path of a sample saved model.
MODEL_GCS_DIR = 'gs://cloud-samples-data/vision/edge_container_predict/'
SAMPLE_SAVED_MODEL = MODEL_GCS_DIR + 'saved_model.pb'
SAMPLE_SAVED_MODEL = 'gs://cloud-samples-data/vision/edge_container_predict/saved_model.pb'
# Container Name.
NAME = 'AutomlVisionEdgeContainerPredictTest'
# Port Number.
Expand All @@ -56,8 +56,8 @@ def edge_container_predict_server_port():
# set up
# Pull the CPU docker.
subprocess.check_output(['docker', 'pull', CPU_DOCKER_GCS_PATH])
# Get the sample saved model.

# Get the sample saved model.
if not os.path.exists(MODEL_PATH):
os.mkdir(MODEL_PATH)
subprocess.check_output(
Expand All @@ -79,18 +79,16 @@ def edge_container_predict_server_port():
# Remove the docker image.
subprocess.check_output(['docker', 'rmi', CPU_DOCKER_GCS_PATH])

# TODO(dizcology): Enable tests in future.
@pytest.mark.skip(reason='skipping to avoid running docker in docker')

def test_edge_container_predict(capsys, edge_container_predict_server_port):
image_file_path = 'test.jpg'
# If you send requests with one image each time, the key value does not
# matter. If you send requests with multiple images, please used different
# keys to indicated different images, which can make sure that the
# responses corresponding to the given image.
image_key = '1'
# Send a request.
response = predict.container_predict(
image_file_path, image_key, PORT_NUMBER)
IMAGE_FILE_PATH, image_key, PORT_NUMBER)
# Verify the response.
assert 'predictions' in response
assert 'key' in response['predictions'][0]
Expand Down