Skip to content

Commit

Permalink
Fix continuous integration (#68)
Browse files Browse the repository at this point in the history
* Update GitHub Actions

* Reformat with Ruff

* Replace black by Ruff

* Remove unused import

* Fix documentation badge

* Update Python version in various configs
  • Loading branch information
bittremieux authored Apr 21, 2024
1 parent 40151e2 commit 6dbf9bf
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 89 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ name: Lint

on:
push:
branches:
- main
- dev
branches: [ main, dev ]
pull_request:
branches:
- main
- dev
branches: [ main, dev ]

jobs:
lint:
Expand All @@ -20,13 +16,15 @@ jobs:
with:
python-version: "3.12"

- name: Lint with black
uses: psf/black@stable
- name: Install Ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with Ruff
run: |
ruff check . --output-format=github
- name: Check for debugging print statements
- name: Check formatting with Ruff
run: |
if grep -rq "print(" spectrum_utils; then
echo "Found the following print statements:"
grep -r "print(" spectrum_utils
exit 1
fi
ruff format --check .
7 changes: 2 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# This workflows will upload a Python Package using Twine when a release is created.
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: PyPI
name: Publish to PyPI

on:
release:
types: [created]
types: [ created ]

jobs:
deploy:
Expand Down
35 changes: 11 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: tests
name: Run tests

on:
push:
branches:
- main
- dev
branches: [ main, dev ]
pull_request:
branches:
- main
- dev
branches: [ main, dev ]
schedule:
- cron: "0 0 1 1/1 *" # Run monthly.

Expand All @@ -20,8 +13,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
Expand All @@ -32,21 +25,15 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov wheel
pip install -e .
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names.
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
# The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install uv
uv pip install pytest pytest-cov wheel --system
uv pip install -e . --system
- name: Run unit and system tests
run: |
pytest --cov=spectrum_utils tests/
pytest --cov=spectrum_utils --verbose tests/
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
16 changes: 11 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 22.8.0 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.1
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2

python:
version: 3.8
version: 3.10
install:
- method: pip
path: .
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![conda](https://img.shields.io/conda/vn/bioconda/spectrum_utils?color=green)](http://bioconda.github.io/recipes/spectrum_utils/README.html)
[![PyPI](https://img.shields.io/pypi/v/spectrum_utils?color=green)](https://pypi.org/project/spectrum_utils/)
[![Build status](https://github.com/bittremieux/spectrum_utils/workflows/tests/badge.svg)](https://github.com/bittremieux/spectrum_utils/actions?query=workflow:tests)
[![docs](https://readthedocs.org/projects/spectrum_utils/badge/?version=latest)](https://spectrum_utils.readthedocs.io/en/latest/?badge=latest)
[![docs](https://readthedocs.org/projects/spectrum-utils/badge/?version=latest)](https://spectrum-utils.readthedocs.io/en/latest/?badge=latest)

spectrum_utils is a Python package for efficient mass spectrometry data processing and visualization.

Expand All @@ -18,7 +18,7 @@ spectrum_utils contains the following features:

## Installation

spectrum_utils requires Python version 3.8+ and can be installed with pip or conda.
spectrum_utils requires Python version 3.10+ and can be installed with pip or conda.

Using pip:

Expand Down
1 change: 0 additions & 1 deletion docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

sys.path.insert(0, os.path.abspath(os.path.join("..", "..")))

import pyteomics.usi
import spectrum_utils


Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![conda](https://img.shields.io/conda/vn/bioconda/spectrum_utils?color=green)](http://bioconda.github.io/recipes/spectrum_utils/README.html)
[![PyPI](https://img.shields.io/pypi/v/spectrum_utils?color=green)](https://pypi.org/project/spectrum_utils/)
[![Build status](https://github.com/bittremieux/spectrum_utils/workflows/tests/badge.svg)](https://github.com/bittremieux/spectrum_utils/actions?query=workflow:tests)
[![docs](https://readthedocs.org/projects/spectrum_utils/badge/?version=latest)](https://spectrum_utils.readthedocs.io/en/latest/?badge=latest)
[![docs](https://readthedocs.org/projects/spectrum_utils/badge/?version=latest)](https://spectrum-utils.readthedocs.io/en/latest/?badge=latest)

## About spectrum_utils

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dependencies:
- pandas
- platformdirs
- pyteomics>=4.5
- python>=3.8
- python>=3.10
28 changes: 5 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
[build-system]
requires = ['setuptools>=45', 'wheel', 'setuptools_scm[toml]>=6.0']
build-backend = 'setuptools.build_meta'
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.black]
[tool.ruff]
line-length = 79
target-version = ['py312']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''
target-version = "py310"
include = ["*.py"]
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers =
[options]
packages = find:
include_package_data = True
python_requires = >=3.8
python_requires = >=3.10
install_requires =
fastobo
lark>=1.0
Expand All @@ -34,9 +34,9 @@ install_requires =

[options.extras_require]
dev =
black
pytest
pytest-cov
ruff
docs =
myst-parser
numpydoc>=1.1.0
Expand Down
9 changes: 6 additions & 3 deletions spectrum_utils/proforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,9 @@ def parse(proforma: str) -> List[Proteoform]:


@functools.lru_cache
def _import_cv(cv_id: str, cache: Optional[str]) -> Union[
def _import_cv(
cv_id: str, cache: Optional[str]
) -> Union[
Tuple[Dict[str, Tuple[float, str]], Dict[str, Tuple[float, str]]],
Dict[str, float],
]:
Expand Down Expand Up @@ -869,8 +871,9 @@ def _parse_obo(
):
term_mass = float(
term_xref[
term_xref.index('"')
+ 1 : term_xref.rindex('"')
term_xref.index('"') + 1 : term_xref.rindex(
'"'
)
]
)
elif (
Expand Down
14 changes: 7 additions & 7 deletions spectrum_utils/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def remove_precursor_peak(
fragment_tol_mass: float,
fragment_tol_mode: str,
isotope: int = 0,
) -> "MsmsSpectrumJit":
) -> MsmsSpectrumJit:
# TODO: This assumes [M+H]x charged ions.
adduct_mass = 1.007825
neutral_mass = (
Expand Down Expand Up @@ -504,19 +504,19 @@ def remove_precursor_peak(
"""
Remove fragment peak(s) close to the precursor m/z.
Note: This peak manipulation will reset any ProForma annotations that
were applied previously.
Note: This peak manipulation will reset any ProForma annotations
that were applied previously.
Parameters
----------
fragment_tol_mass : float
Fragment mass tolerance around the precursor mass to remove the
precursor peak.
Fragment mass tolerance around the precursor mass to remove
the precursor peak.
fragment_tol_mode : {'Da', 'ppm'}
Fragment mass tolerance unit. Either 'Da' or 'ppm'.
isotope : int
The number of precursor isotopic peaks to be checked (the default
is 0 to check only the mono-isotopic peaks).
The number of precursor isotopic peaks to be checked (the
default is 0 to check only the mono-isotopic peaks).
Returns
-------
Expand Down

0 comments on commit 6dbf9bf

Please sign in to comment.