-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from gymrek-lab/citrus-package-setup
Initial package setup with poetry and tests
- Loading branch information
Showing
20 changed files
with
3,604 additions
and
2,536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Tests | ||
|
||
on: [pull_request, workflow_call] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.session }} / ${{ matrix.python }} / ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- { python: "3.11", os: "ubuntu-latest", session: "tests" } | ||
- { python: "3.12", os: "ubuntu-latest", session: "tests" } | ||
|
||
env: | ||
NOXSESSION: ${{ matrix.session }} | ||
FORCE_COLOR: "1" | ||
PRE_COMMIT_COLOR: "always" | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Mambaforge | ||
uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
activate-environment: citrus | ||
miniforge-variant: Mambaforge | ||
auto-activate-base: false | ||
miniforge-version: latest | ||
use-mamba: true | ||
|
||
- name: Get Date | ||
id: get-date | ||
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Cache Conda env | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.CONDA }}/envs | ||
key: | ||
conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('dev-env.yml') }}-${{ env.CACHE_NUMBER }} | ||
env: | ||
# Increase this value to reset cache if dev-env.yml has not changed | ||
CACHE_NUMBER: 0 | ||
id: cache | ||
|
||
- name: Install dev environment | ||
run: | ||
mamba env update -n citrus -f dev-env.yml | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
|
||
- name: Try to build citrus | ||
shell: bash -el {0} | ||
run: | | ||
poetry build --no-ansi | ||
- name: Check distribution size | ||
if: matrix.session == 'size' | ||
run: | | ||
du -csh dist/* | ||
tar -ztvf dist/*.tar.gz | ||
# check that the generated dist/ directory does not exceed 0.3 MB | ||
# if this check fails, it's because you forgot to list large files in the "exclude" section of our pyproject.toml | ||
# https://python-poetry.org/docs/pyproject/#include-and-exclude | ||
[ $(du -b dist | cut -f1) -lt 300000 ] | ||
- name: Check code coverage | ||
if: matrix.session == 'coverage' | ||
shell: bash -el {0} | ||
run: | | ||
export NOXSESSION=tests | ||
# check that code coverage is not lower than specific percent | ||
nox --verbose --python=${{ matrix.python }} -- --cov=. --cov-report=term-missing --cov-fail-under=0 # TODO update!! | ||
- name: Run tests with nox | ||
if: matrix.session == 'tests' | ||
shell: bash -el {0} | ||
run: | | ||
nox --verbose --python=${{ matrix.python }} | ||
large-files: | ||
name: File sizes | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for large files | ||
uses: actionsdesk/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} # Optional | ||
filesizelimit: 500000b | ||
labelName: large-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from importlib.metadata import version, PackageNotFoundError | ||
|
||
try: | ||
__version__ = version(__name__) | ||
except PackageNotFoundError: | ||
__version__ = "unknown" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pytest | ||
|
||
# To check pytest framework is working | ||
def test_dummy(): | ||
assert True |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
- nodefaults | ||
dependencies: | ||
- conda-forge::python=3.11 # the lowest version of python that we formally support | ||
- conda-forge::pip==24.0 | ||
- conda-forge::poetry==1.8.3 # keep in sync with release.yml | ||
- conda-forge::nox==2024.4.15 | ||
- conda-forge::poetry-plugin-export==1.8.0 | ||
- anaconda::graphviz==2.50.0 | ||
- pip: | ||
- nox-poetry==1.0.3 | ||
- poetry-conda==0.1.1 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"input": [ | ||
{ | ||
"file": "example-files/example_gts_chr19.vcf.gz", | ||
"file_format": "vcf", | ||
"reference_genome": "GRCh37", | ||
"force_bgz": true, | ||
"input_nodes": [ | ||
{ | ||
"alias": "chr19_280540_G_A", | ||
"type": "SNP", | ||
"chr": "19", | ||
"pos": 280540 | ||
}, | ||
{ | ||
"alias": "chr19_523746_C_T", | ||
"type": "SNP", | ||
"chr": "19", | ||
"pos": [523746] | ||
} | ||
] | ||
} | ||
], | ||
"simulation_steps": [ | ||
{ | ||
"type": "Constant", | ||
"alias": "chr19_280540_G_A_beta", | ||
"input_match_size": "chr19_280540_G_A", | ||
"constant": 0.1 | ||
}, | ||
{ | ||
"type": "Constant", | ||
"alias": "chr19_523746_C_T_beta", | ||
"input_match_size": "chr19_523746_C_T", | ||
"constant": 0.3 | ||
}, | ||
{ | ||
"type": "Product", | ||
"alias": "chr19_280540_G_A_effect", | ||
"input_aliases": [ | ||
"chr19_280540_G_A_beta", "chr19_280540_G_A" | ||
] | ||
}, | ||
{ | ||
"type": "Product", | ||
"alias": "chr19_523746_C_T_effect", | ||
"input_aliases": [ | ||
"chr19_523746_C_T_beta", "chr19_523746_C_T" | ||
] | ||
}, | ||
{ | ||
"type": "Concatenate", | ||
"alias": "effects_by_haplotype", | ||
"input_aliases": [ | ||
"chr19_280540_G_A_effect", | ||
"chr19_523746_C_T_effect" | ||
] | ||
}, | ||
{ | ||
"type": "AdditiveCombine", | ||
"alias": "effects", | ||
"input_alias": "effects_by_haplotype" | ||
}, | ||
{ | ||
"type": "SumReduce", | ||
"alias": "phenotype", | ||
"input_alias": "effects" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Nox sessions.""" | ||
import os | ||
from pathlib import Path | ||
|
||
import nox | ||
from nox_poetry import Session | ||
from nox_poetry import session | ||
|
||
|
||
package = "citrus" | ||
python_versions = ["3.11", "3.12"] | ||
nox.needs_version = ">= 2022.11.21" | ||
nox.options.sessions = ( | ||
"tests", | ||
) | ||
|
||
|
||
cov_cli_args = [ | ||
"--cov=.", | ||
"--cov-report=term-missing", | ||
] | ||
|
||
|
||
def install_handle_python(session): | ||
""" | ||
handle incompatibilities between python and other packages | ||
see https://github.com/cjolowicz/nox-poetry/issues/1116 | ||
""" | ||
# install the latest versions of all dependencies for py3.9+ | ||
# but install the locked versions for < py3.9 to ensure some stability in the CI and | ||
# help us understand when we need to bump our version constraints | ||
if session._session.python in ("3.9", "3.10", "3.11", "3.12"): | ||
session._session.install(".") | ||
else: | ||
session.install(".") | ||
|
||
|
||
# detect whether conda/mamba is installed | ||
if os.getenv("CONDA_EXE"): | ||
conda_cmd = "conda" | ||
if (Path(os.getenv("CONDA_EXE")).parent / "mamba").exists(): | ||
conda_cmd = "mamba" | ||
conda_args = ["-c", "conda-forge"] | ||
|
||
@session(venv_backend=conda_cmd, venv_params=conda_args, python=python_versions) | ||
def tests(session: Session) -> None: | ||
"""Run the test suite.""" | ||
session.conda_install( | ||
"numpy", | ||
"pytest", | ||
"pytest-cov", | ||
channel="conda-forge", | ||
) | ||
install_handle_python(session) | ||
session.run( | ||
"python", "-m", "pytest", *cov_cli_args, *session.posargs | ||
) | ||
session.run("./test/cmdline_tests.sh", external=True) | ||
else: | ||
|
||
@session(python=python_versions) | ||
def tests(session: Session) -> None: | ||
"""Run the test suite.""" | ||
session.install("pytest", "pytest-cov") | ||
install_handle_python_numpy(session) | ||
session.run( | ||
"python", "-m", "pytest", *cov_cli_args, *session.posargs | ||
) | ||
session.run("./test/cmdline_tests.sh", external=True) |
Oops, something went wrong.