Skip to content

Commit

Permalink
Merge pull request #6 from bento-platform/asyncify
Browse files Browse the repository at this point in the history
Asyncify with Quart + add Docker container CI building
  • Loading branch information
davidlougheed authored Dec 1, 2022
2 parents d69429b + 5a518dc commit bf678ac
Show file tree
Hide file tree
Showing 26 changed files with 2,177 additions and 326 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.coverage
.github
.mypy_cache
.tox
env
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and push bento_service_registry
on:
release:
types: [ published ]
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build-push:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run Bento build action
uses: bento-platform/[email protected]
with:
registry: ghcr.io
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
image-name: ghcr.io/bento-platform/bento_service_registry
development-dockerfile: dev.Dockerfile
dockerfile: Dockerfile
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ jobs:
- uses: actions/setup-python@v2
name: Set up Python
with:
python-version: 3.6
- name: Install flake8
run: python -m pip install flake8
python-version: "3.8"
- name: Install poetry
run: python -m pip install poetry
- name: Install dependencies
run: python -m poetry install --only dev
- name: Run linter
run: flake8 ./bento_service_registry ./tests
run: python -m flake8 ./bento_service_registry ./tests
- name: Run type checker
run: python -m mypy bento_service_registry
21 changes: 5 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.9 ]
python-version: [ "3.8", "3.10" ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
name: Set up Python
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: python -m pip install poetry
- name: Install Python dependencies
run: python -m pip install -r requirements.txt
run: python -m poetry install
- name: Test
run: pytest -svv --cov=bento_service_registry --cov-branch
run: python -m pytest -svv --cov=bento_service_registry --cov-branch
- name: Codecov
run: codecov
install:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.9 ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
name: Set up Python
with:
python-version: ${{ matrix.python-version }}
- name: Install bento_service_registry
run: python -m pip install .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
__pycache__
env/
.coverage
.mypy_cache
.tox
htmlcov/
.idea/workspace.xml
.idea/dataSources*
Expand Down
2 changes: 2 additions & 0 deletions .idea/dictionaries/davidlougheed.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ghcr.io/bento-platform/bento_base_image:python-debian-latest

# Use uvicorn (instead of hypercorn) in production since I've found
# multiple benchmarks showing it to be faster - David L
RUN pip install --no-cache-dir poetry==1.2.2 "uvicorn[standard]==0.20.0"

# Backwards-compatible with old BentoV2 container layout
WORKDIR /service-registry

COPY pyproject.toml pyproject.toml
COPY poetry.toml poetry.toml
COPY poetry.lock poetry.lock

# Install production dependencies
# Without --no-root, we get errors related to the code not being copied in yet.
# But we don't want the code here, otherwise Docker cache doesn't work well.
RUN poetry install --without dev --no-root

# Manually copy only what's relevant
# (Don't use .dockerignore, which allows us to have development containers too)
COPY bento_service_registry bento_service_registry
COPY entrypoint.sh entrypoint.sh
COPY LICENSE LICENSE
COPY README.md README.md

# Install the module itself, locally (similar to `pip install -e .`)
RUN poetry install --without dev

CMD [ "sh", "./entrypoint.sh" ]
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@

**Author:** David Lougheed, Canadian Centre for Computational Genomics

Prototype implementation of GA4GH's [service registry API](https://github.com/ga4gh-discovery/ga4gh-service-registry/)
Prototype implementation of the GA4GH [service registry API](https://github.com/ga4gh-discovery/ga4gh-service-registry/)
for the Bento platform.


## Development

### Running the Service
### Getting set up

1. Create a virtual environment for the project:
```bash
virtualenv -p python3 ./env
source env/bin/activate
```
2. Install `poetry`:
```bash
pip install poetry
```
3. Install project dependencies:
```bash
poetry install
```

To run the service, use the following command:
### Running the service locally

To run the service in development mode, use the following command:

```bash
FLASK_DEBUG=True FLASK_APP=bento_service_registry.app flask run
QUART_ENV=development QUART_APP=bento_service_registry.app quart run
```

### Running tests
Expand All @@ -27,6 +44,7 @@ To run tests and linting, run Tox:
tox
```


## Configuration

The following environment variables are used to configure the
Expand Down
10 changes: 3 additions & 7 deletions bento_service_registry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import configparser
import os
from importlib import metadata

__all__ = ["name", "__version__"]

config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(os.path.realpath(__file__)), "package.cfg"))

name = config["package"]["name"]
__version__ = config["package"]["version"]
name = __package__
__version__ = metadata.version(__package__)
Loading

0 comments on commit bf678ac

Please sign in to comment.