Skip to content

Commit

Permalink
Merge pull request #8 from eipm/develop
Browse files Browse the repository at this point in the history
v.1.0.0
  • Loading branch information
alexsigaras authored Jan 30, 2023
2 parents 2de1417 + a771a79 commit 95bbdb1
Show file tree
Hide file tree
Showing 36 changed files with 1,763 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
README.md

.git
.github
**/stork_v/models
**/data
86 changes: 86 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Docker

on:
push:
# Publish `main` as Docker `latest` image and `develop` as `develop` image.
branches:
- main
- develop

# Publish `v1.2.3` tags as releases.
tags:
- v*

# Run tests for any PRs.
pull_request:

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: stork-v

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into GitHub Container Registry
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login https://ghcr.io -u ${{ secrets.GHCR_SVC_ACCOUNT }} --password-stdin

- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention for main and `develop` for develop
[ "$VERSION" == "main" ] && VERSION=latest
[ "$VERSION" == "develop" ] && VERSION=develop
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Login to EIPM DockerHub
uses: docker/#-action@v1
with:
username: ${{ secrets.EIPM_DOCKER_HUB_USERNAME }}
password: ${{ secrets.EIPM_DOCKER_HUB_TOKEN }}

- name: Push image to EIPM Docker Hub
run: |
IMAGE_ID=eipm/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention for main and `develop` for develop
[ "$VERSION" == "main" ] && VERSION=latest
[ "$VERSION" == "develop" ] && VERSION=develop
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ dmypy.json

# Pyre type checker
.pyre/

# Model files
*Model

# zip and avi files
*.zip
!src/static/assets/images/test-images.zip
*.avi
**/data/**
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"env": {
"USERS_DICT": "{'user1': 'stork'}",
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true,
"justMyCode": true
}
]
}
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:3.8.16-slim
#===============================#
# Docker Image Configuration #
#===============================#
LABEL org.opencontainers.image.source='https://github.com/eipm/stork-v' \
vendor='Englander Institute for Precision Medicine' \
description='STORK-V' \
maintainer='paz2010@med.cornell.edu' \
base_image='python' \
base_image_version='3.8.16-slim'

ENV APP_NAME='stork-v' \
TZ='US/Eastern'

#===================================#
# Install Prerequisites #
#===================================#
COPY requirements.txt /${APP_NAME}/requirements.txt
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
RUN pip install --upgrade pip && pip install -r /${APP_NAME}/requirements.txt
#===================================#
# Copy Files and set work directory #
#===================================#
COPY src /${APP_NAME}
WORKDIR /${APP_NAME}
#===================================#
# Startup #
#===================================#
EXPOSE 80
ENV PATH=$PATH:/${APP_NAME}
ENV PYTHONPATH /${APP_NAME}
VOLUME /${APP_NAME}/data
VOLUME /${APP_NAME}/temp
VOLUME /${APP_NAME}/stork_v/models

HEALTHCHECK --interval=30s --timeout=30s --retries=3 \
CMD curl -f -k http://0.0.0.0/api/healthcheck || exit 1

CMD python3 /${APP_NAME}/main.py
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# stork-v
# stork-v

[![Actions Status](https://github.com/eipm/stork-v/workflows/Docker/badge.svg)](https://github.com/eipm/stork-v/actions) [![Github](https://img.shields.io/badge/github-1.0.0-green?style=flat&logo=github)](https://github.com/eipm/stork-v) [![EIPM Docker Hub](https://img.shields.io/badge/EIPM%20docker%20hub-1.0.0-blue?style=flat&logo=docker)](https://hub.docker.com/repository/docker/eipm/stork-v) [![GitHub Container Registry](https://img.shields.io/badge/GitHub%20Container%20Registry-1.0.0-blue?style=flat&logo=docker)](https://github.com/orgs/eipm/packages/container/package/stork-v) [![Python 3.8.16](https://img.shields.io/badge/python-3.8.16-blue.svg)](https://www.python.org/downloads/release/python-360/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Set up local environment and install dependencies

Install requirements from requirements.txt
`pip install -r requirements.txt`

Add the models in the folder
`src/stork_v/models`

## Execute a model as script

Add the zip file in the expeted location `src/data/78645636.zip` and run the command
`python src/test.py`

## Docker run command


```
PATH_TO_MODELS=<set the location of your models directory>
PATH_TO_DATA=<set the location of you data directory>
PATH_TO_TEMP=<set the location of the temp directory used for creating the videos>
docker run --name stork-v \
-v $PATH_TO_MODELS:/stork-v/stork_v/models \
-v $PATH_TO_DATA:/stork-v/data \
-v $PATH_TO_TEMP:/stork-v/temp \
-e USERS_DICT="{'user1': 'stork'}" \
-p 8080:80 \
stork-v
```
56 changes: 56 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
absl-py==1.3.0
astunparse==1.6.3
cachetools==5.2.0
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
Flask==2.2.2
Flask-Cors==3.0.10
flatbuffers==2.0.7
gast==0.4.0
google-auth==2.15.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.51.1
h5py==3.7.0
idna==3.4
importlib-metadata==5.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
joblib==1.2.0
keras==2.7.0
Keras-Preprocessing==1.1.2
libclang==14.0.6
Markdown==3.4.1
MarkupSafe==2.1.1
marshmallow==3.19.0
numpy==1.23.5
oauthlib==3.2.2
opencv-python==4.6.0.66
opt-einsum==3.3.0
packaging==22.0
pandas==1.5.2
protobuf==3.20.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
python-dateutil==2.8.2
pytz==2022.6
requests==2.28.1
requests-oauthlib==1.3.1
rsa==4.9
scikit-learn==1.2.0
scipy==1.9.3
six==1.16.0
tensorboard==2.11.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.7.0
tensorflow-estimator==2.7.0
tensorflow-io-gcs-filesystem==0.28.0
termcolor==2.1.1
threadpoolctl==3.1.0
typing_extensions==4.4.0
urllib3==1.26.13
Werkzeug==2.2.2
wrapt==1.14.1
zipp==3.11.0
24 changes: 24 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# 4 space indentation
[*.{py,html}]
indent_style = space
indent_size = 4

# 2 space indentation
[*.{js,json,y{a,}ml,cwl}]
indent_style = space
indent_size = 2

[*.{md}]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2
Loading

0 comments on commit 95bbdb1

Please # to comment.