Skip to content

Commit e9e9129

Browse files
authored
Cleanups, updates to documentation, UV, remove ununsed modules (#111)
1 parent b4ff24d commit e9e9129

File tree

110 files changed

+8285
-4775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+8285
-4775
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@
33
This package implements different workflows for CI.
44
They are organised as follows.
55

6-
### Documentation
6+
## Documentation
77

8-
The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful).
9-
It runs on `ubuntu-latest` and `Python 3.9`.
8+
The `documentation` workflow builds the documentation.
9+
It runs on `ubuntu-latest` and the latest supported Python version.
10+
If the workflow is run from `master` it pushes the successfully build documentation to the `gh-pages` branch.
11+
If run from a `pull_request` the documentation is uploaded as an artifact to allow manual checks.
1012

11-
### Testing Suite
13+
## Testing Suite
1214

13-
Tests are ensured in the `tests` workflow, which triggers on all pushes.
14-
Tests run on a matrix of all GitHub Actions supported operating systems for all supported Python versions (currently `3.8+`).
15+
Tests are ensured in the `tests` workflow.
16+
Tests run on a matrix of all supported operating systems and all currently supported Python versions.
1517

16-
### Test Coverage
18+
## Test Coverage
1719

18-
Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`.
19-
It runs on `ubuntu-latest` and `Python 3.9`, and reports the coverage results of the test suite to `Codecov`.
20+
Test coverage is calculated in the `coverage` workflow.
21+
It runs on `ubuntu-latest` and our latest supported Python version, and reports the coverage results of the test suite to `Codecov`.
2022

21-
### Regular Testing
23+
## Regular Testing
2224

23-
A `cron` workflow triggers every Saturday at 12:00 (UTC time) and runs the full testing suite, on all GitHub Actions supported operating systems for all supported Python versions (currently `3.8+`).
24-
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically detected and reported.
25+
A `cron` workflow triggers every Saturday at 12:00 (UTC time) and runs the full testing suite, on all supported operating systems and supported Python versions.
26+
It is very similar to the normal Testing Suite, but in addition also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included.
2527

26-
### Publishing
28+
## Publishing
2729

28-
Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the GitHub repository and runs on `ubuntu-latest` and `Python 3.9`.
29-
It builds a source distribution (`tar.gz`) and a `wheel` of the package, and pushes to `PyPI` if the builds are successful.
30-
No matrix is needed for this build as `pyhdtoolkit` is a pure python package and generates `*-py3-none-any.whl` wheels.
30+
Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made on GitHub.
31+
It runs on `ubuntu-latest` and the latest supported Python version.
32+
33+
It builds the package (source distribution and `wheel`), checks the created artifacts, and pushes to `PyPI` if checks are successful.
34+
No matrix is needed for this build as `pyhdtoolkit` is a pure python package and generates `*-py3-none-any.whl` wheels.

.github/workflows/coverage.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222

23-
- name: Set up Python ${{ env.python-version }}
24-
uses: actions/setup-python@v5
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v3
2525
with:
26-
python-version: ${{ env.python-version }}
27-
cache: 'pip'
28-
cache-dependency-path: '**/pyproject.toml'
26+
enable-cache: true
27+
cache-dependency-glob: pyproject.toml
2928

30-
- name: Upgrade pip, setuptools and wheel
31-
run: python -m pip install --upgrade pip setuptools wheel
29+
- name: Set up Python ${{ env.python-version }}
30+
run: uv python install ${{ env.python-version }}
3231

3332
- name: Install package with test dependencies
34-
run: python -m pip install ".[test]"
33+
run: uv sync --all-extras --dev
3534

3635
- name: Get acc-models-lhc
3736
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
3837

3938
- name: Run all tests
40-
run: make alltests
39+
run: make tests
4140

4241
- name: Upload Coverage to Codecov
4342
uses: codecov/codecov-action@v4

.github/workflows/cron.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
2727
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/pyproject.toml'
31-
32-
- name: Upgrade pip, setuptools and wheel
33-
run: python -m pip install --upgrade pip setuptools wheel
34-
28+
enable-cache: true
29+
cache-dependency-glob: pyproject.toml
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
run: uv python install ${{ matrix.python-version }}
33+
3534
- name: Install package with test dependencies
36-
run: python -m pip install ".[test]"
35+
run: uv sync --all-extras --dev
3736

3837
- name: Get acc-models-lhc
3938
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
4039

4140
- name: Run Tests
42-
run: make alltests
41+
run: make tests

.github/workflows/documentation.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ jobs:
2929
- name: Install optipng, dvipng and cm-super
3030
run: sudo apt-get install -y optipng dvipng cm-super
3131

32-
- name: Set up Python ${{ env.python-version }}
33-
uses: actions/setup-python@v5
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v3
3434
with:
35-
python-version: ${{ env.python-version }}
36-
cache: 'pip'
37-
cache-dependency-path: '**/pyproject.toml'
38-
39-
- name: Upgrade pip, setuptools and wheel
40-
run: python -m pip install --upgrade pip setuptools wheel
35+
enable-cache: true
36+
cache-dependency-glob: pyproject.toml
37+
38+
- name: Set up Python ${{ env.python-version }}
39+
run: uv python install ${{ env.python-version }}
4140

42-
- name: Install package with doc dependencies
43-
run: python -m pip install ".[docs]"
41+
- name: Install package with test dependencies
42+
run: uv sync --all-extras --dev
4443

4544
- name: Get acc-models-lhc
4645
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1

.github/workflows/publish.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- name: Install hatch
23-
run: pipx install hatch
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v3
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: pyproject.toml
27+
28+
- name: Set up Python ${{ env.python-version }}
29+
run: uv python install ${{ env.python-version }}
2430

2531
- name: Build wheels and sdist
2632
run: make build

.github/workflows/tests.yml

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on: # Runs on any push event to any branch except master (the coverage workflow
1010
- 'master'
1111

1212
jobs:
13-
quick_tests:
13+
tests:
1414
name: ${{ matrix.os }} / ${{ matrix.python-version }}
1515
runs-on: ${{ matrix.os }}
1616
strategy:
@@ -22,44 +22,17 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
2727
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: pip
30-
cache-dependency-path: '**/pyproject.toml'
31-
32-
- name: Install package with test dependencies
33-
run: python -m pip install ".[test]"
34-
35-
- name: Run Tests
36-
run: make quicktests
37-
38-
cpymad_tests:
39-
needs: quick_tests
40-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
41-
runs-on: ${{ matrix.os }}
42-
strategy:
43-
matrix:
44-
os: [ubuntu-22.04, ubuntu-24.04, macos-latest, windows-latest]
45-
python-version: ["3.10", 3.11, 3.12]
46-
fail-fast: false
47-
48-
steps:
49-
- uses: actions/checkout@v4
28+
enable-cache: true
29+
cache-dependency-glob: pyproject.toml
5030

5131
- name: Set up Python ${{ matrix.python-version }}
52-
uses: actions/setup-python@v5
53-
with:
54-
python-version: ${{ matrix.python-version }}
55-
cache: pip
56-
cache-dependency-path: '**/pyproject.toml'
57-
58-
- name: Install package
59-
run: python -m pip install ".[test]"
60-
61-
- name: Get acc-models-lhc
62-
run: git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
32+
run: uv python install ${{ matrix.python-version }}
33+
34+
- name: Install package with test dependencies
35+
run: uv sync --all-extras --dev
6336

6437
- name: Run Tests
65-
run: make slowtests
38+
run: make tests

Makefile

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,31 @@ D = \033[34m # dark blue
1212
E = \033[0m # end
1313
P = \033[95m # pink
1414
R = \033[31m # red
15-
# Y = \033[33m # yellow
15+
Y = \033[33m # yellow
1616

17-
.PHONY : help build clean docker docs format install lines lint typing alltests quicktests slowtests
17+
.PHONY : help build clean docker docs format install lines lint typing tests
1818

1919
all: install
2020

2121
help:
2222
@echo "Please use 'make $(R)<target>$(E)' where $(R)<target>$(E) is one of:"
23-
@echo " $(R) build $(E) \t to build wheel and source distribution with $(P)Hatch$(E)."
24-
@echo " $(R) clean $(E) \t to recursively remove build, run and bitecode files/dirs."
25-
@echo " $(R) docker $(E) \t to build a $(P)Docker$(E) container image replicating said environment (and other goodies)."
26-
@echo " $(R) docs $(E) \t to build the documentation for the package with $(P)Sphinx$(E)."
27-
@echo " $(R) format $(E) \t to recursively apply PEP8 formatting through the $(P)Black$(E) and $(P)isort$(E) cli tools."
28-
@echo " $(R) install $(E) \t to $(C)pip install$(E) this package into the current environment."
29-
@echo " $(R) lines $(E) \t to count lines of code with the $(P)tokei$(E) tool."
30-
@echo " $(R) lint $(E) \t to lint the code though $(P)Pylint$(E)."
31-
@echo " $(R) typing $(E) \t to run type checking on the codebase with $(P)MyPy$(E)."
32-
@echo " $(R) alltests $(E) \t to run the full test suite with $(P)pytest$(E)."
33-
@echo " $(R) quicktests $(E) \t to run tests not involving $(D)pyhdtoolkit.cpymadtools$(E) with $(P)Pytest$(E)."
34-
@echo " $(R) slowtests $(E) \t to run tests involving $(D)pyhdtoolkit.cpymadtools$(E) with $(P)Pytest$(E)."
35-
36-
37-
# ----- Dev Tools Targets ----- #
23+
@echo " $(R) build $(E) to build wheel and source distribution with $(P)uv$(E)."
24+
@echo " $(R) clean $(E) to recursively remove build, run and bitecode files/dirs."
25+
@echo " $(R) docker $(E) to build a $(P)Docker$(E) container image replicating said environment (and other goodies)."
26+
@echo " $(R) docs $(E) to build the documentation for the package with $(P)Sphinx$(E)."
27+
@echo " $(R) format $(E) to recursively apply PEP8 formatting through the $(P)Black$(E) and $(P)isort$(E) cli tools."
28+
@echo " $(R) install $(E) to install this package into the current environment (editable install)."
29+
@echo " $(R) lines $(E) to count lines of code with the $(P)tokei$(E) tool."
30+
@echo " $(R) lint $(E) to lint the code though $(P)Ruff$(E)."
31+
@echo " $(R) tests $(E) to run the test suite with $(P)pytest$(E) (parallelized)."
32+
33+
34+
# ----- Dev Targets ----- #
3835

3936
build:
4037
@echo "Re-building wheel and dist"
4138
@rm -rf dist
42-
@hatch build --clean
39+
@uv build
4340
@echo "Created build is located in the $(C)dist$(E) folder."
4441

4542
clean:
@@ -49,7 +46,7 @@ clean:
4946
@echo "Cleaning up sphinx-gallery build artifacts."
5047
@rm -rf docs/gallery
5148
@rm -rf docs/gen_modules
52-
@echo "Cleaning up distutils remains."
49+
@echo "Cleaning up package build remains."
5350
@rm -rf build
5451
@rm -rf dist
5552
@rm -rf pyhdtoolkit.egg-info
@@ -61,6 +58,7 @@ clean:
6158
@echo "Cleaning up pytest cache & test artifacts."
6259
@find . -type d -name '*.pytest_cache' -exec rm -rf {} + -o -type f -name '*.pytest_cache' -exec rm -rf {} +
6360
@find . -type f -name 'fc.*' -delete -o -type f -name 'fort.*' -delete
61+
@find . -type f -name 'checkpoint_restart.*' -delete -o -type f -name 'internal_mag_pot.*' -delete
6462
@echo "Cleaning up mypy cache."
6563
@find . -type d -name "*.mypy_cache" -exec rm -rf {} +
6664
@echo "Cleaning up coverage reports."
@@ -75,41 +73,30 @@ docker:
7573

7674
docs:
7775
@echo "Building static pages with $(D)Sphinx$(E)."
78-
@python -m sphinx -v -b html docs doc_build -d doc_build
76+
@uv run python -m sphinx -v -b html docs doc_build -d doc_build
7977

8078
format:
81-
@echo "Formatting code to PEP8 with $(P)isort$(E) and $(P)Black$(E) for $(C)docs$(E), $(C)pyhdtoolkit$(E) and $(C)tests$(E) folders. Max line length is 120 characters."
82-
@python -m isort . && black .
83-
@echo "Formatting code to PEP8 with $(P)isort$(E) and $(P)Black$(E) for $(C)examples$(E) folder. Max line length is 95 characters."
84-
@python -m isort examples && black -l 95 examples
85-
86-
install: format clean
87-
@echo "Installing (editable) with $(D)pip$(E) in the current environment."
88-
@python -m pip install --editable . -v
89-
90-
lines: format
79+
@echo "Formatting code in $(C)docs$(E), $(C)tests$(E) and $(C)pyhdtoolkit$(E)."
80+
@uvx isort docs && uvx black docs
81+
@uvx isort tests && uvx black tests
82+
@uvx isort pyhdtoolkit && uvx black pyhdtoolkit
83+
@echo "Formatting code to PEP8 with $(P)isort$(E) and $(P)Black$(E) for $(C)examples$(E) folder."
84+
@uvx isort examples && uvx black -l 95 examples
85+
86+
install:
87+
@echo "Installing (editable) the package in the current environment."
88+
@uv pip install --editable .
89+
90+
lines:
91+
@echo "Counting lines of code with $(P)tokei$(E)."
9192
@tokei .
9293

93-
lint: format
94-
@echo "Linting code with $(P)Pylint$(E)."
95-
@python -m pylint pyhdtoolkit/
96-
97-
typing: format
98-
@echo "Checking code typing with $(P)mypy$(E)."
99-
@python -m mypy pyhdtoolkit
100-
@make clean
101-
102-
103-
# ----- Tests Targets ----- #
104-
105-
quicktests: # all tests not involving pyhdtoolkit.cpymadtools
106-
@python -m pytest -k "not test_cpymadtools" -n auto -v
107-
108-
slowtests: # all tests for pyhdtoolkit.cpymadtools
109-
@python -m pytest -k "test_cpymadtools" -n auto -v
94+
lint:
95+
@echo "Linting code with $(P)Ruff$(E)."
96+
@uvx ruff check pyhdtoolkit
11097

111-
alltests:
112-
@python -m pytest -n auto -v
98+
tests:
99+
@uv run python -m pytest -n auto -v
113100

114101
# Catch-all unknow targets without returning an error. This is a POSIX-compliant syntax.
115102
.DEFAULT:

0 commit comments

Comments
 (0)