-
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 #2 from mmcdermott/dev
Updated build environment and linted files.
- Loading branch information
Showing
28 changed files
with
769 additions
and
359 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,27 @@ | ||
# Same as `code-quality-pr.yaml` but triggered on commit to main branch | ||
# and runs on all files (instead of only the changed ones) | ||
|
||
name: Code Quality Main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run pre-commits | ||
uses: pre-commit/[email protected] |
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,41 @@ | ||
# This workflow finds which files were changed, prints them, | ||
# and runs `pre-commit` on those files. | ||
|
||
# Inspired by the sktime library: | ||
# https://github.com/alan-turing-institute/sktime/blob/main/.github/workflows/test.yml | ||
|
||
name: Code Quality PR | ||
|
||
on: | ||
pull_request: | ||
branches: [main, "release/*", "dev"] | ||
|
||
jobs: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Find modified files | ||
id: file_changes | ||
uses: trilom/[email protected] | ||
with: | ||
output: " " | ||
|
||
- name: List modified files | ||
run: echo '${{ steps.file_changes.outputs.files}}' | ||
|
||
- name: Run pre-commits | ||
uses: pre-commit/[email protected] | ||
with: | ||
extra_args: --files ${{ steps.file_changes.outputs.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/ml-mixins | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--notes "" | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' |
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,48 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main, "release/*", "dev"] | ||
|
||
jobs: | ||
run_tests_ubuntu: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
fail-fast: false | ||
|
||
timeout-minutes: 30 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install packages | ||
run: | | ||
pip install -e .[tests,tqdmable,tensorable] | ||
#---------------------------------------------- | ||
# run test suite | ||
#---------------------------------------------- | ||
- name: Run tests | ||
run: | | ||
pytest -v --doctest-modules --cov=src --junitxml=junit.xml -s --ignore=docs | ||
- name: Upload coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Upload test results to Codecov | ||
if: ${{ !cancelled() }} | ||
uses: codecov/test-results-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
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,133 @@ | ||
default_language_version: | ||
python: python3.12 | ||
|
||
exclude: "docs/index.md|MIMIC-IV_Example/README.md|eICU_Example/README.md" | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
# list of supported hooks: https://pre-commit.com/hooks.html | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-docstring-first | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- id: check-executables-have-shebangs | ||
- id: check-toml | ||
- id: check-case-conflict | ||
- id: check-added-large-files | ||
args: [--maxkb, "800"] | ||
|
||
# python code formatting | ||
- repo: https://github.com/psf/black | ||
rev: 23.7.0 | ||
hooks: | ||
- id: black | ||
args: [--line-length, "110"] | ||
|
||
# python import sorting | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files", "-o", "wandb"] | ||
|
||
- repo: https://github.com/PyCQA/autoflake | ||
rev: v2.2.0 | ||
hooks: | ||
- id: autoflake | ||
args: [--in-place, --remove-all-unused-imports] | ||
|
||
# python upgrading syntax to newer version | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.10.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py311-plus] | ||
|
||
# python docstring formatting | ||
- repo: https://github.com/myint/docformatter | ||
rev: v1.7.5 | ||
hooks: | ||
- id: docformatter | ||
args: [--in-place, --wrap-summaries=110, --wrap-descriptions=110] | ||
|
||
# python check (PEP8), programming errors and code complexity | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
[ | ||
"--max-complexity=10", | ||
"--extend-ignore", | ||
"E402,E701,E251,E226,E302,W504,E704,E402,E401,C901,E203", | ||
"--max-line-length=110", | ||
"--exclude", | ||
"logs/*,data/*", | ||
"--per-file-ignores", | ||
"__init__.py:F401", | ||
] | ||
|
||
# yaml formatting | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.3 | ||
hooks: | ||
- id: prettier | ||
types: [yaml] | ||
exclude: "environment.yaml" | ||
|
||
# shell scripts linter | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.9.0.5 | ||
hooks: | ||
- id: shellcheck | ||
|
||
# md formatting | ||
- repo: https://github.com/executablebooks/mdformat | ||
rev: 0.7.17 | ||
hooks: | ||
- id: mdformat | ||
args: ["--number"] | ||
additional_dependencies: | ||
- mdformat-gfm | ||
- mdformat-tables | ||
- mdformat_frontmatter | ||
- mdformat-black | ||
- mdformat-config | ||
- mdformat-shfmt | ||
- mdformat-mkdocs | ||
- mdformat-toc | ||
- mdformat-admon | ||
|
||
# word spelling linter | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.2.5 | ||
hooks: | ||
- id: codespell | ||
args: | ||
- --skip=logs/**,data/**,*.ipynb,*.bib,env.yml,env_cpu.yml,*.svg,poetry.lock | ||
- --ignore-words-list=ehr,crate | ||
|
||
# jupyter notebook cell output clearing | ||
- repo: https://github.com/kynan/nbstripout | ||
rev: 0.6.1 | ||
hooks: | ||
- id: nbstripout | ||
|
||
# jupyter notebook linting | ||
- repo: https://github.com/nbQA-dev/nbQA | ||
rev: 1.7.0 | ||
hooks: | ||
- id: nbqa-black | ||
args: ["--line-length=110"] | ||
- id: nbqa-isort | ||
args: ["--profile=black"] | ||
- id: nbqa-flake8 | ||
args: | ||
[ | ||
"--extend-ignore=E203,E402,E501,F401,F841", | ||
"--exclude=logs/*,data/*", | ||
] |
Oops, something went wrong.