Skip to content

Commit

Permalink
Merge pull request #22 from UKPLab/model-api
Browse files Browse the repository at this point in the history
Added first version of Model API to Square
  • Loading branch information
Aaronsom authored Aug 10, 2021
2 parents f44654e + d3c047e commit dbf3570
Show file tree
Hide file tree
Showing 65 changed files with 3,363 additions and 0 deletions.
182 changes: 182 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,185 @@ jobs:
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
model-api:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="ukpsquare/square-model-api"
echo ::set-output name=image::${IMAGE}
echo ::set-output name=tag::${TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-model_api-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-model_api-
${{ runner.os }}-buildx-
- name: Build test image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./square-model-inference-api/inference_server
target: test
load: true
tags: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}-test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Retrieve Test Reports
id: extract
uses: shrink/actions-docker-extract@v1
with:
image: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}-test
path: /app/test-reports

- uses: actions/upload-artifact@v2
with:
name: model_api-test-reports
path: ${{ steps.extract.outputs.destination }}/test-reports

- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
with:
report_paths: ${{ steps.extract.outputs.destination }}/test-reports/junit.xml
check_name: Model API Test Report
fail_on_failure: true

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build deployable image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./square-model-inference-api/inference_server
target: build
push: ${{github.ref == 'refs/heads/master'}}
tags: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}, ${{ steps.prep.outputs.image }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
model-api-auth:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="ukpsquare/square-model-api-auth"
echo ::set-output name=image::${IMAGE}
echo ::set-output name=tag::${TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-model_api_auth-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-model_api_auth-
${{ runner.os }}-buildx-
- name: Build test image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./square-model-inference-api/auth_server
target: test
load: true
tags: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}-test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Retrieve Test Reports
id: extract
uses: shrink/actions-docker-extract@v1
with:
image: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}-test
path: /app/test-reports

- uses: actions/upload-artifact@v2
with:
name: model_api_auth-test-reports
path: ${{ steps.extract.outputs.destination }}/test-reports

- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
with:
report_paths: ${{ steps.extract.outputs.destination }}/test-reports/junit.xml
check_name: Model API Auth Test Report
fail_on_failure: true

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build deployable image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./square-model-inference-api/auth_server
target: build
push: ${{github.ref == 'refs/heads/master'}}
tags: ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}, ${{ steps.prep.outputs.image }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
38 changes: 38 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,44 @@ services:
ports:
- 80:80

### MODEL API
model_auth:
image: ukpsquare/square-model-api-auth:latest
container_name: square_model_auth
ports:
- 8081:8081
env_file:
- ./square-model-inference-api/auth_server/.env

model_nginx:
image: nginx
ports:
- 8080:8080
volumes:
- ./square-model-inference-api/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

inference_bert_adapter:
image: ukpsquare/square-model-api:latest
ports:
- 8000:8000
env_file:
- ./square-model-inference-api/inference_server/.env.bert_adapter
container_name: square_model_inference_bert_adapter
volumes:
- ./.cache/:/etc/huggingface/.cache/

inference_dpr:
image: ukpsquare/square-model-api:latest
ports:
- 8001:8000
env_file:
- ./square-model-inference-api/inference_server/.env.dpr
container_name: square_model_inference_dpr
volumes:
- ./.cache/:/etc/huggingface/.cache/

### / MODEL API Finished

#adminer:
# image: adminer
# restart: always
Expand Down
134 changes: 134 additions & 0 deletions square-model-inference-api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/images
/tests
.ascii-art

*.yml
*.ini

# Hidden files
.DS_store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# data is not logged
data/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
.vscode/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
htmlcov-py36/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.model_testing_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

.vscode/
.pytest-cache/
.pytest_cache/
.empty/

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.idea/



Child_Watch_API/
htmlcov-*/

# remove large model
ml_model/*.joblib


#venv
venv/

.idea/
Loading

0 comments on commit dbf3570

Please sign in to comment.