Skip to content

Commit

Permalink
Merge branch 'master' into jw/type-hint-commands-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob37 committed Jan 31, 2025
2 parents 3a7830d + b70777d commit d13edf6
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 111 deletions.
33 changes: 13 additions & 20 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
name: Run tests and upload coverage

on: ["push", "pull_request"]
# This workflow installs Gens and runs test suite
name: CI

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
test-python:
python-unit-tests:
name: Coverage
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: ["3.11", "3.12"]
mongodb-version: ["7"]

steps:

# Check out Scout code
- uses: actions/checkout@v4

# Set up python
- name: Set up Python ${{ matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version}}

- name: Production Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
pip install pytest-cov
pip install coveralls
- name: Test with pytest & Coveralls
run: |
pip install -r requirements-dev.txt
- name: Run unit-tests and coveralls
run: |
pytest --cov=./
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

test-js:

js-unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [17.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/)

About changelog [here](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Changed
- Migrated from setup.py to pyproject.toml using hatchling
- Updated python to version 3.12 and thawed some dependencies.

## 3.0.1

Expand Down
46 changes: 29 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
# BUILDER PYTHON #
##################

FROM python:3.8.1-slim AS python-builder
FROM python:3.12 AS python-builder

# Set build variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /usr/src/app
COPY MANIFEST.in setup.py setup.cfg requirements.txt ./

COPY gens gens/
COPY README.md LICENSE pyproject.toml ./

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends python3-pip \
python3-wheel && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir gunicorn && \
pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels \
--requirement requirements.txt
pip install --no-cache-dir hatch && \
hatch build -t wheel /usr/src/app/wheels
#pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels --requirement requirements.txt \


################
# BUILDER NODE #
Expand All @@ -34,37 +37,46 @@ RUN npm install && npm run build
# FINAL #
#########

FROM python:3.8.1-slim
FROM python:3.12-slim

LABEL base_image="python:3.8.1-slim"
LABEL base_image="python:3.12-slim"
LABEL about.home="https://github.com/Clinical-Genomics-Lund/Gens"

# Run commands as non-root user
RUN useradd -m app && mkdir -p /home/app/app
WORKDIR /home/app/app
# Create non-root user to run Gens
RUN groupadd --gid 1000 worker \
&& useradd -g worker --uid 1000 --shell /user/sbin/nologin --create-home worker

# Copy pyhon wheels and install software
# Copy project to worker dir
WORKDIR /home/worker

# Copy pyhon wheels
COPY --from=python-builder /usr/src/app/wheels /wheels

# Install production dependencies
RUN apt-get update && \
apt-get install -y ssh sshfs && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir /wheels/* && \
pip install --no-cache-dir gunicorn && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /wheels

# Chown all the files to the app user
COPY gens gens
COPY utils utils
COPY --chown=worker:worker gens ./gens
COPY --chown=worker:worker utils ./utils

# copy compiled web assetes
COPY --from=node-builder /usr/src/app/build/css/error.min.css gens/static/css/
COPY --from=node-builder /usr/src/app/build/css/home.min.css /usr/src/app/build/css/landing.min.css /usr/src/app/build/css/about.min.css gens/blueprints/home/static/
COPY --from=node-builder /usr/src/app/build/*/gens.min.* gens/blueprints/gens/static/

# make mountpoints and change ownership of app
RUN mkdir -p /access /fs1/results /fs1/results_dev && chown -R app:app /home/app/app /access /fs1 /fs1/results_dev
# Change the user to app
USER app
RUN mkdir -p /access /fs1/results /fs1/results_dev && \
chown -R worker:worker /access /fs1 /fs1/results_dev

# Setup non-root user and variables
USER worker

ENV GUNICORN_WORKERS=1
ENV GUNICORN_THREADS=1
Expand All @@ -76,11 +88,11 @@ CMD gunicorn \
--bind=$GUNICORN_BIND \
--threads=$GUNICORN_THREADS \
--timeout=$GUNICORN_TIMEOUT \
--chdir /home/app/app/ \
--chdir /home/worker/ \
--proxy-protocol \
--forwarded-allow-ips="10.0.2.100,127.0.0.1" \
--log-syslog \
--access-logfile - \
--error-logfile - \
--log-level="debug" \
--log-level="warning" \
gens.wsgi:app
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN npm install && npm run build
# FINAL #
#########

FROM python:3.8.1
FROM python:3.12

# Create non-root user to run Gens
RUN groupadd --gid 1000 worker \
Expand All @@ -28,7 +28,7 @@ WORKDIR /home/worker
# Chown all the files to the app user
COPY --chown=worker:worker gens ./gens
COPY --chown=worker:worker utils ./utils
COPY --chown=worker:worker setup.cfg setup.py ./
COPY --chown=worker:worker README.md LICENSE pyproject.toml ./

# copy compiled web assetes
COPY --chown=worker:worker --from=node-builder /usr/src/app/build/css/error.min.css gens/static/css/
Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "Gens"
dynamic = ["version"]
description = 'Visualise copy number profiles from WGS data'
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
keywords = ["WGS", "scout", "CNV", "cancer", "rare disease", "variant", "NGS", "browser"]
authors = [
{ name = "Markus Johansson", email = "[email protected]" },
{ name = "Jakob Willforss", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"Click",
"Flask",
"flask-caching",
"flask_login",
"authlib",
"pymongo",
"gtfparse",
"pysam",
"pyyaml",
"attrs",
"cattrs",
"connexion==2.14.2",
"flask-compress",
"tabulate",
]

[project.urls]
Documentation = "https://github.com/SMD-Bioinformatics-Lund/gens#readme"
Issues = "https://github.com/SMD-Bioinformatics-Lund/gens/issues"
Changelog = "https://github.com/SMD-Bioinformatics-Lund/gens/blob/master/CHANGELOG.md"

[project.scripts]
gens = "gens.commands:cli"

[tool.hatch.version]
path = "gens/__version__.py"

[tool.hatch.build]
include = [
"gens/templates/*.html",
"gens/static/**/*",
"gens/static/**/*",
"gens/blueprints/**/static/*",
"gens/openapi/openapi.yaml",
]

[tool.hatch.build.targets.wheel]
packages = ["gens"]

[tool.hatch.envs.types]
extra-dependencies = [
"mypy>=1.0.0",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/temporary tests}"

[tool.coverage.run]
source_pkgs = ["gens", "tests"]
branch = true
parallel = true
omit = [
"gens/__version__.py",
]

[tool.coverage.paths]
gens = ["gens",]
tests = ["tests", "*/temporary/tests"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[tool.isort]
profile = "black"
src_paths = ["gens"]
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytest
pytest-cov
pytest-flask
pytest-mongodb
coveralls

# utils
black
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.

59 changes: 0 additions & 59 deletions setup.py

This file was deleted.

0 comments on commit d13edf6

Please sign in to comment.