forked from ksamuk/pixy
-
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.
feat: Codebase Improvements - Regression Testing and CI/CD
tests: add testing data for future regression tests (#5) tests: add shared fixtures + helper function in conftest.py; add __init__.py (#6) tests: add tests for missing, invalid, or conflicting arguments (ksamuk#7) tests: add tests for problematic arguments (ksamuk#8) tests: add tests for warnings and valid `pixy` inputs (ksamuk#9) respond to reviewer comments; ruff + mypy checks ci: add`ruff` to environment.yaml; style and lint `pixy` code (ksamuk#15) chore: Move `pyproject.toml` to top-level (ksamuk#16) * chore: move pyproject to top level * chore: ruff format ci: initial `mypy` on existing `pixy` files (ksamuk#14) tests: add additional coverage for edge cases (ksamuk#18) * tests: add new testing data for oddballs and edge cases * tests: add additional testing conditions (WIP) * bools should not be optional unless we have a good reason * style for sites_path variable feat: Add poetry and fix up GHA issues (ksamuk#28) This PR adds the usual `poetry` configuration to the pyproject.toml, so Python dependencies and our static analysis checks can be managed with `poetry`. In addition, the following associated changes were made: - `ruff format` was applied to the codebase - `ruff check --fix` was applied to the `tests/`module. - The existing files - `pixy/__main__.py`, `pixy/core.py`, and `pixy/calc.py` - are **temporarily** excluded from ruff linting. Upcoming contributions should be added to different files **or** resolve all existing issues in any updated files in the course of making changes. - Python dependencies and `pixy` were removed from the `environment.yaml`, which is now only used to manage the `samtools` dependency. - NB: We should likely refactor to use `pysam` instead of subprocess calls to the samtools suite, which may end up obviating the need for any env yaml whatsoever. Would be nice if this could be hosted on pypi - I added the GHA workflow from our python template - A few lingering type issues were addressed. - The GHA workflow was modified to include `conda` and install samtools/htslib via conda - A `CONTRIBUTING.md` was added, including development installation instructions. chore: rm pycache files (ksamuk#33) These snuck through before the `.gitignore` was updated chore: change conda env name (ksamuk#34) To be consistent with the CONTRIBUTING docs ci: upgrade `htslib` and `samtools` versions to accomodate wider spread of python versions (ksamuk#35)
- Loading branch information
Showing
47 changed files
with
125,718 additions
and
726 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,68 @@ | ||
name: Code checks | ||
|
||
on: [push] | ||
|
||
env: | ||
POETRY_VERSION: 1.8.2 | ||
|
||
jobs: | ||
Tests: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.PYTHON_VERSION }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.PYTHON_VERSION }} | ||
|
||
- name: Set up miniconda and install samtools | ||
uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
miniforge-version: latest | ||
channels: conda-forge,bioconda | ||
activate-environment: pixy-dev | ||
auto-activate-base: false | ||
environment-file: environment.yaml | ||
channel-priority: flexible | ||
auto-update-conda: true | ||
python-version: ${{ matrix.PYTHON_VERSION }} | ||
|
||
- name: Get full Python version | ||
id: full-python-version | ||
shell: bash | ||
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT | ||
|
||
- name: Install poetry | ||
run: | | ||
python -m pip install --upgrade pipx | ||
pipx install poetry==${{env.POETRY_VERSION}} | ||
- name: Set up cache | ||
uses: actions/cache@v4 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Ensure cache is healthy | ||
if: steps.cache.outputs.cache-hit == 'true' | ||
shell: bash | ||
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv | ||
|
||
- name: Install the library | ||
shell: bash -el {0} | ||
run: | | ||
poetry install -v | ||
- name: Test the library | ||
shell: bash -el {0} | ||
run: | | ||
poetry run ruff format --check --diff | ||
poetry run ruff check | ||
poetry run mypy | ||
poetry run pytest | ||
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 |
---|---|---|
|
@@ -8,3 +8,5 @@ data/vcf | |
.ipynb_checkpoints/* | ||
output/* | ||
docs/_build | ||
|
||
__pycache__/ |
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,106 @@ | ||
# Development and Testing | ||
|
||
## Installing development version of pixy | ||
|
||
Create a fresh conda environment with Python 3.8, install samtools and htslib | ||
1.9 using the provided `environment.yaml`, and then install `pixy` and its | ||
Python dependencies with poetry. | ||
|
||
```console | ||
mamba create -n pixy-dev python=3.8 | ||
mamba env update -f environment.yaml | ||
poetry install | ||
``` | ||
|
||
## Primary Development Commands | ||
|
||
To check and resolve linting issues in the codebase, run: | ||
|
||
```console | ||
poetry run ruff check --fix | ||
``` | ||
|
||
To check and resolve formatting issues in the codebase, run: | ||
|
||
```console | ||
poetry run ruff format | ||
``` | ||
|
||
To check the unit tests in the codebase, run: | ||
|
||
```console | ||
poetry run pytest | ||
``` | ||
|
||
To check the typing in the codebase, run: | ||
|
||
```console | ||
poetry run mypy | ||
``` | ||
|
||
To generate a code coverage report after testing locally, run: | ||
|
||
```console | ||
poetry run coverage html | ||
``` | ||
|
||
To check the lock file is up to date: | ||
|
||
```console | ||
poetry check --lock | ||
``` | ||
|
||
## Shortcut Task Commands | ||
|
||
To be able to run shortcut task commands, first install the Poetry plugin [`poethepoet`](https://poethepoet.natn.io/index.html): | ||
|
||
```console | ||
poetry self add 'poethepoet[poetry_plugin]' | ||
``` | ||
|
||
> [!NOTE] | ||
> Upon the release of Poetry [v2.0.0](https://github.com/orgs/python-poetry/discussions/9793#discussioncomment-11043205), Poetry will automatically support bootstrap installation of [project-specific plugins](https://github.com/python-poetry/poetry/pull/9547) and installation of the task runner will become automatic for this project. | ||
> The `pyproject.toml` syntax will be: | ||
> | ||
> ```toml | ||
> [tool.poetry] | ||
> requires-poetry = ">=2.0" | ||
> | ||
> [tool.poetry.requires-plugins] | ||
> poethepoet = ">=0.29" | ||
> ``` | ||
###### For Running Individual Checks | ||
```console | ||
poetry task check-lock | ||
poetry task check-format | ||
poetry task check-lint | ||
poetry task check-tests | ||
poetry task check-typing | ||
``` | ||
###### For Running All Checks | ||
|
||
```console | ||
poetry task check-all | ||
``` | ||
|
||
###### For Running Individual Fixes | ||
|
||
```console | ||
poetry task fix-format | ||
poetry task fix-lint | ||
``` | ||
|
||
###### For Running All Fixes | ||
|
||
```console | ||
poetry task fix-all | ||
``` | ||
|
||
###### For Running All Fixes and Checks | ||
|
||
```console | ||
poetry task fix-and-check-all | ||
``` |
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,8 @@ | ||
name: pixy-dev | ||
channels: | ||
- bioconda | ||
- conda-forge | ||
dependencies: | ||
- bioconda::htslib=1.21 | ||
- bioconda::samtools=1.21 | ||
|
Oops, something went wrong.