Skip to content

Commit

Permalink
Merge 3084b1e into 87869fb
Browse files Browse the repository at this point in the history
  • Loading branch information
willgraf committed Oct 6, 2020
2 parents 87869fb + 3084b1e commit 70878af
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 49 deletions.
22 changes: 17 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,36 @@ python:
- 3.5
- 3.6
- 3.7
- 3.8

cache: pip

install:
- pip install -r requirements.txt
- pip install pytest pytest-cov==2.5.1 pytest-pep8 coveralls
- pip install --upgrade -r requirements-test.txt

script:
- pytest --pep8 --cov=writers
- pytest --pep8 --cov writers

jobs:
include:
- stage: deploy
- stage: deploy_writer
if: tag IS present
python: 3.6
python: 3.7
script:
- export IMAGE_NAME="${TRAVIS_REPO_SLUG}-config-writer"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker build -t "$TRAVIS_REPO_SLUG" .
- docker build -t "$IMAGE_NAME" -f docker/Dockerfile.writer .
- docker images
- docker tag "$IMAGE_NAME" "$IMAGE_NAME":latest
- docker tag "$IMAGE_NAME" "$IMAGE_NAME":"${TRAVIS_TAG}"
- docker push "$IMAGE_NAME"
- stage: deploy_server
if: tag IS present
python: 3.7
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker build -t "$TRAVIS_REPO_SLUG" -f docker/Dockerfile.serving .
- docker images
- docker tag "$TRAVIS_REPO_SLUG" "$TRAVIS_REPO_SLUG":latest
- docker tag "$TRAVIS_REPO_SLUG" "$TRAVIS_REPO_SLUG":"${TRAVIS_TAG}"
Expand Down
28 changes: 0 additions & 28 deletions bin/entrypoint.sh

This file was deleted.

14 changes: 14 additions & 0 deletions bin/serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

tensorflow_model_server \
--port=$PORT \
--rest_api_port=$REST_API_PORT \
--rest_api_timeout_in_ms=$REST_API_TIMEOUT \
--model_config_file=$MODEL_CONFIG_FILE \
--enable_batching=$ENABLE_BATCHING \
--grpc_channel_arguments=$GRPC_CHANNEL_ARGS \
--tensorflow_session_parallelism=$TF_SESSION_PARALLELISM \
--monitoring_config_file=$MONITORING_CONFIG_FILE \
--batching_parameters_file=$BATCHING_CONFIG_FILE \
&& \
/bin/bash # hack to keep from exiting
15 changes: 15 additions & 0 deletions bin/write.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# write the configuration files before running the server
python write_config_file.py \
--cloud-provider=$CLOUD_PROVIDER \
--model-prefix=$MODEL_PREFIX \
--file-path=$MODEL_CONFIG_FILE \
--monitoring-enabled=$PROMETHEUS_MONITORING_ENABLED \
--monitoring-path=$PROMETHEUS_MONITORING_PATH \
--monitoring-file-path=$MONITORING_CONFIG_FILE \
--enable-batching=$MONITORING_CONFIG_FILE \
--max-batch-size=$MAX_BATCH_SIZE \
--batch-timeout=$BATCH_TIMEOUT_MICROS \
--max-enqueued-batches=$MAX_ENQUEUED_BATCHES \
--batch-file-path=$BATCHING_CONFIG_FILE
43 changes: 43 additions & 0 deletions docker/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2016-2020 The Van Valen Lab at the California Institute of
# Technology (Caltech), with support from the Paul Allen Family Foundation,
# Google, & National Institutes of Health (NIH) under Grant U24CA224309-01.
# All rights reserved.
#
# Licensed under a modified 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.github.com/vanvalenlab/kiosk-tf-serving/LICENSE
#
# The Work provided may be used for non-commercial academic purposes only.
# For any other use of the Work, including commercial use, please contact:
# vanvalenlab@gmail.com
#
# Neither the name of Caltech nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# 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.
# ============================================================================

FROM tensorflow/serving:1.15.0-gpu

ENV PORT=8500 \
REST_API_PORT=8501 \
REST_API_TIMEOUT=30000 \
ENABLE_BATCHING=true \
TF_CPP_MIN_LOG_LEVEL=0 \
AWS_LOG_LEVEL=3 \
GRPC_CHANNEL_ARGS="" \
TF_SESSION_PARALLELISM=0 \
MODEL_CONFIG_FILE=/config/models.conf \
BATCHING_CONFIG_FILE=/config/batching_config.txt \
MONITORING_CONFIG_FILE=/config/monitoring_config.txt

COPY ./bin/serve.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT "/usr/local/bin/entrypoint.sh"
24 changes: 8 additions & 16 deletions Dockerfile → docker/Dockerfile.writer
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,12 @@
# limitations under the License.
# ============================================================================

# Using official tensorflow-serving as base image
ARG TF_SERVING_VERSION=1.15.0
ARG TF_SERVING_BUILD_IMAGE=tensorflow/serving:${TF_SERVING_VERSION}-devel-gpu
FROM python:3.7-slim-buster

FROM ${TF_SERVING_BUILD_IMAGE}
WORKDIR /usr/src/app

WORKDIR /kiosk/tf-serving

ENV PORT=8500 \
REST_API_PORT=8501 \
REST_API_TIMEOUT=30000 \
ENABLE_BATCHING=true \
TF_CPP_MIN_LOG_LEVEL=0 \
AWS_LOG_LEVEL=3 \
GRPC_CHANNEL_ARGS="" \
TF_SESSION_PARALLELISM=0 \
ENV CLOUD_PROVIDER=aws \
MODEL_PREFIX=models \
PROMETHEUS_MONITORING_ENABLED=true \
PROMETHEUS_MONITORING_PATH=/monitoring/prometheus/metrics \
MODEL_CONFIG_FILE=/kiosk/tf-serving/models.conf \
Expand All @@ -54,6 +44,8 @@ COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

# Copy python script to generate model configuration file
COPY . .
COPY writers write_config_file.py /usr/src/app/

COPY ./bin/write.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT "./bin/entrypoint.sh"
ENTRYPOINT "/usr/local/bin/entrypoint.sh"
4 changes: 4 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest<6
pytest-cov
pytest-pep8
coveralls

0 comments on commit 70878af

Please sign in to comment.