From 0058571df323a0d9eecc4cb9bb2f23a399ffa801 Mon Sep 17 00:00:00 2001 From: Brendan Dwyer Date: Mon, 9 Mar 2020 14:22:56 -0700 Subject: [PATCH] Add ARM automation and readme updates --- .travis.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- README.md | 19 +++++++++++++++---- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b3b276..ad804aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,59 @@ +# +# Copyright 2018-2020 IBM Corp. All Rights Reserved. +# +# 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. +# + language: python python: - 3.6 services: - docker + +before_install: + # Replace all slashes (which are common in branch names) in VERSION with dashes for Docker compatibility + - if [[ "$TRAVIS_BRANCH" == "master" ]]; then + VERSION=latest; + else + VERSION=${TRAVIS_BRANCH//\//-}; + fi + + # Default variables (used by Jenkins) + - '[[ -z "$DOCKERFILE" ]] && export DOCKERFILE=Dockerfile || /bin/true' + - '[[ -z "$IMAGE" ]] && export IMAGE=test || /bin/true' + - '[[ -z "$ARCH" ]] && export ARCH=x86_64 || /bin/true' + - '[[ -z "$VERSION" ]] && export VERSION=jenkins || /bin/true' + install: - - docker build -t max-audio-classifier . - - docker run -it -d -p 5000:5000 max-audio-classifier + - docker build -f "$DOCKERFILE" -t codait/max-audio-classifier:"$IMAGE"-"$ARCH"-"$VERSION" . + - docker run -it -d --rm -p 5000:5000 codait/max-audio-classifier:"$IMAGE"-"$ARCH"-"$VERSION" - pip install pytest requests flake8 before_script: - flake8 . --max-line-length=127 - sleep 30 script: - pytest tests/test.py + +after_success: + - if [[ "$IMAGE" != "test" && "$TRAVIS_PULL_REQUEST" == "false" ]] && [[ "$TRAVIS_BRANCH" == "master" || "$TRAVIS_BRANCH" == "$TRAVIS_TAG" ]]; then + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin; + docker push codait/max-audio-classifier:"$IMAGE"-"$ARCH"-"$VERSION"; + fi + +matrix: + include: + - os: linux + env: DOCKERFILE=Dockerfile IMAGE=test ARCH=x86_64 + - os: linux + arch: arm64 + env: DOCKERFILE=Dockerfile.arm32v7 IMAGE=arm ARCH=arm32v7 \ No newline at end of file diff --git a/README.md b/README.md index 63d184b..aa0098d 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,17 @@ arXiv:1609.09430, 2016. To run the docker image, which automatically starts the model serving API, run: -``` + +Intel CPUs: +```bash $ docker run -it -p 5000:5000 codait/max-audio-classifier ``` +ARM CPUs (eg Raspberry Pi): +```bash +$ docker run -it -p 5000:5000 codait/max-audio-classifier:arm-arm32v7-latest +``` + This will pull a pre-built image from Docker Hub (or use an existing image if already cached locally) and run it. If you'd rather checkout and build the model locally you can follow the [run locally](#run-locally) steps below. @@ -109,12 +116,16 @@ Change directory into the repository base folder: $ cd MAX-Audio-Classifier ``` -To build the Docker image locally, run: - -``` +To build the docker image locally for Intel CPUs, run: +```bash $ docker build -t max-audio-classifier . ``` +For ARM CPUs (eg Raspberry Pi), run: +```bash +$ docker build -f Dockerfile.arm32v7 -t max-object-detector . +``` + All required model assets will be downloaded during the build process. _Note_ that currently this Docker image is CPU only (we will add support for GPU images later).