Skip to content

Commit

Permalink
feat: use pydantic models for validation (#496)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Blanc <[email protected]>
Co-authored-by: Nicolai-vKuegelgen <[email protected]>
  • Loading branch information
3 people authored and sellth committed Jun 28, 2024
1 parent cccfd16 commit bf39678
Show file tree
Hide file tree
Showing 234 changed files with 7,939 additions and 4,644 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"

- name: Install dependencies
run: |
Expand All @@ -42,10 +42,9 @@ jobs:
uses: marocchino/[email protected]
with:
message: |
- Please format your Python code with [black](https://black.readthedocs.io): `make black`
- Please format your Python code with [ruff](https://docs.astral.sh/ruff/): `make fmt`
- Please check your Python code with [ruff](https://docs.astral.sh/ruff/): `make check`
- Please format your Snakemake code with [snakefmt](https://github.com/snakemake/snakefmt): `make snakefmt`
- Please organize your imports [isorts](https://isort.readthedocs.io): `make isort`
- Please ensure that your code passes [flake8](https://flake8.pycqa.org/en/latest/): `make flake8`
You can trigger all lints locally by running `make lint`
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -58,11 +57,12 @@ jobs:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"

- name: Install dependencies
run: |
pip install -r requirements/test.txt
pip install -r requirements/base.txt -r requirements/test.txt
pip install -e .
pip freeze
- name: Build documentation
Expand All @@ -75,7 +75,7 @@ jobs:
strategy:
matrix:
python-version:
- "3.10"
- "3.12"
# - "3.11" # no compatible pysam yet
# - "3.12" # no compatible pysam yet
needs: linting
Expand All @@ -95,7 +95,7 @@ jobs:
- name: Prepare environment.yml file
run: >
cp environment.yml /tmp/environment.yml && sed -i -e
's/- python/- python=${{ matrix.python-version }}/'
's/- python=.*/- python=${{ matrix.python-version }}/'
/tmp/environment.yml
- name: Update environment using mamba
run: mamba env update --name root --file /tmp/environment.yml
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.4.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
2 changes: 1 addition & 1 deletion .tests/test-workflow/config/cancer_wes/config.yaml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ step_config:


somatic_variant_calling:
path_ngs_mapping: ../ngs_mapping
tools: [mutect2]
mutect2:
ngs_mapping: ../ngs_mapping
extra_arguments: []
window_length: 300000000
keep_tmpdir: onerror
Expand Down
2 changes: 1 addition & 1 deletion .tests/test-workflow/workflow/envs/snappy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:

# Fundamentals
- python >=3.11.0
- python >=3.12.0
- pip =24
- git-lfs =3.5
- gcc_linux-64 =13.2
Expand Down
8 changes: 4 additions & 4 deletions .tests/test-workflow/workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def folder_names(pipeline: str) -> list[str]:

def reference_path() -> str:
if chrom := config["reference"].get("chromosome", None):
return f"resources/refs/{chrom}.fa.gz"
return "resources/refs/" + chrom + ".fa.gz"
else:
return "resources/refs/genome.fa.gz"

Expand All @@ -33,8 +33,8 @@ def reference_faidx_region_string(wildcards) -> str:
region = config["reference"].get("region", None)
match chrom, region:
case None, None:
return f""
return ""
case chrom, None:
return f"{chrom}"
return chrom
case chrom, region:
return f"{chrom}:{region}"
return chrom + ":" + region
35 changes: 14 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,42 @@ default: help
.PHONY: help
help:
@echo help -- display this help
@echo black -- apply black code formatter
@echo fmt -- apply code formatter
@echo snakefmt -- apply snakefmt code formatter
@echo srcfmt -- apply black and snakefmt formatters
@echo lint -- run linters
@echo test -- run tests through pytest
@echo isort -- run isort
@echo check -- run code checker

.PHONY: black
black:
black -l 100 .
.PHONY: fmt
fmt:
ruff format .

.PHONY: snakefmt
snakefmt:
snakefmt -l 100 . --include '(\.smk$$|\.rules$$|^Snakefile)'

.PHONY: srcfmt
srcfmt: black snakefmt
srcfmt: fmt snakefmt

.PHONY: lint
lint: flake8 lint-black lint-snakefmt lint-isort
lint: check lint-fmt lint-snakefmt

.PHONY: isort
isort:
isort --force-sort-within-sections --profile=black .
.PHONY: check
check:
ruff check .

.PHONY: flake8
flake8:
flake8

.PHONY: lint-black
lint-black:
black -l 100 --check .
.PHONY: lint-fmt
lint-fmt:
ruff format --check .

.PHONY: lint-snakefmt
lint-snakefmt:
snakefmt -l 100 . --include '(\.smk$$|\.rules$$|^Snakefile)' --check

.PHONY: lint-isort
lint-isort:
isort --force-sort-within-sections --profile=black --check .

test:
py.test
pytest

coverage:
coverage report
Expand Down
Loading

0 comments on commit bf39678

Please sign in to comment.