Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update our docker image, linting, and GH actions #7

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build

- name: Build and publish
run: |
python -m build --wheel .

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
python -m pip install --upgrade pip
pip install ruff

- name: Run black
uses: psf/black@stable

- name: Lint with Ruff
run: |
ruff check . --output-format=github

- name: Check formatting with Ruff
run: |
ruff format --check .
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.264
rev: v0.4.10
hooks:
# Run the linter.
- id: ruff
args: ['--fix']
types_or: [ python, pyi, jupyter ]
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
28 changes: 18 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
FROM mambaorg/micromamba:latest
MAINTAINER William E Fondrie <wfondrie@talus.bio>
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml
COPY --chown=$MAMBA_USER:$MAMBA_USER dist/*.whl /tmp/
# Base image for building
FROM python:3.11 as build

WORKDIR /app
# Install essentials:
RUN apt-get update && apt-get install -y build-essential libhdf5-dev

RUN micromamba install -y -n base -f /tmp/environment.yml && \
micromamba clean --all --yes
wfondrie marked this conversation as resolved.
Show resolved Hide resolved
# Install uv:
ADD https://astral.sh/uv/install.sh /install.sh
RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh

ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN WHEEL=$(ls /tmp/*.whl) && pip install ${WHEEL}
# Install our package:
ENV VIRTUAL_ENV=/opt/venv \
PATH="/opt/venv/bin:$PATH"

RUN pip install petasus
ADD . /src
RUN /root/.cargo/bin/uv venv --no-cache /opt/venv && \
/root/.cargo/bin/uv pip install --no-cache /src

# The app stage (slim debian build):
FROM python:3.11-slim-bookworm
COPY --from=build /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
33 changes: 0 additions & 33 deletions environment.yml

This file was deleted.

3 changes: 2 additions & 1 deletion petasus/mzml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
def read(mzml_file: str) -> dict[tuple[np.ndarray, np.ndarray]]:
"""Parse the mzML file

This parser is much faster than Pyteomics, but doesn't do any error checking.
This parser is much faster than Pyteomics, but doesn't do any error
checking.

Parameters
----------
Expand Down
32 changes: 6 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"numba",
"pyarrow",
"hdf5plugin>=3.10.0",
"ms2ml @ git+https://github.com/wfondrie/ms2ml.git@encyclopedia-update"
wfondrie marked this conversation as resolved.
Show resolved Hide resolved
"ms2ml",
]
dynamic = ["version"]

Expand Down Expand Up @@ -56,31 +56,11 @@ find = {namespaces = false}
[tool.setuptools_scm]

[tool.ruff]
line-length = 79
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "T20"] # T20 is for print() statements.
wfondrie marked this conversation as resolved.
Show resolved Hide resolved

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.black]
line-length = 79
target-version = ['py310']
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
)
'''
Loading