Skip to content

Commit 543980c

Browse files
Merge pull request #121 from HERA-Team/modernize-build
maint: modernize build to use uv and ruff
2 parents 7d6aa4f + f6f93ee commit 543980c

31 files changed

Lines changed: 4298 additions & 257 deletions

.github/workflows/run_notebooks.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ jobs:
2525
with:
2626
python-version: "3.13"
2727

28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
30+
with:
31+
enable-cache: true
32+
2833
- name: Install
2934
run: |
30-
echo $(which pip)
31-
pip install .[test] papermill jupyter ipykernel
35+
uv sync --group doctests --locked
3236
3337
- name: Install ipykernel
34-
run: python -m ipykernel install --user --name matvis --display-name "matvis"
38+
run: uv run python -m ipykernel install --user --name matvis --display-name "matvis"
3539

3640
- name: Run Notebooks
3741
run: |
38-
papermill -k matvis docs/tutorials/matvis_tutorial.ipynb tmp.ipynb
42+
uv run papermill -k matvis docs/tutorials/matvis_tutorial.ipynb tmp.ipynb

.github/workflows/test_suite.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,22 @@ jobs:
3333
# - uses: FedericoCarboni/setup-ffmpeg@v2
3434

3535
- name: Setup Python
36-
uses: actions/setup-python@v4
36+
uses: actions/setup-python@v6
3737
with:
3838
python-version: ${{ matrix.python-version }}
3939

40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v7
42+
with:
43+
enable-cache: true
44+
4045
- name: Install
4146
run: |
42-
pip install .[test]
47+
uv sync --dev --locked
4348
4449
- name: Run Tests
4550
run: |
46-
python -m pytest --ignore tests/test_plot.py --cov=matvis --cov-config=.coveragerc --cov-report xml:./coverage.xml --durations=25 --log-cli-level=${{ env.LOG_LEVEL}}
51+
uv run --no-sync pytest --ignore tests/test_plot.py --cov=matvis --cov-config=.coveragerc --cov-report xml:./coverage.xml --durations=25 --log-cli-level=${{ env.LOG_LEVEL }}
4752
4853
- name: Upload coverage report
4954
uses: codecov/codecov-action@v4
@@ -76,14 +81,18 @@ jobs:
7681
with:
7782
fetch-depth: 0
7883

84+
- name: Install uv
85+
uses: astral-sh/setup-uv@v7
86+
with:
87+
enable-cache: true
88+
7989
- name: Install
8090
run: |
8191
echo $(whoami)
8292
source ~/.bashrc
8393
micromamba activate testenv
84-
echo $(which pip)
8594
python -m pip install --upgrade pip
86-
python -m pip install .[test,gpu]
95+
python -m pip install --group dev .[gpu]
8796
8897
- name: Run Tests
8998
run: |

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*.py[cod]
44
*.so
55
*.cfg
6-
!.isort.cfg
7-
!setup.cfg
86
*.orig
97
*.log
108
*.pot

.isort.cfg

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

.pre-commit-config.yaml

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,16 @@ repos:
1717
- id: mixed-line-ending
1818
args: ['--fix=no']
1919

20-
- repo: https://github.com/PyCQA/flake8
21-
rev: 7.3.0
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.15.12
2222
hooks:
23-
- id: flake8
24-
additional_dependencies:
25-
- flake8-docstrings
26-
- flake8-builtins
27-
- flake8-rst-docstrings
28-
- flake8-rst
29-
- flake8-markdown
30-
- flake8-bugbear
31-
- flake8-comprehensions
32-
- flake8-print
33-
34-
- repo: https://github.com/psf/black-pre-commit-mirror
35-
rev: 26.3.1
36-
hooks:
37-
- id: black
23+
- id: ruff-check
24+
types_or: [python, pyi]
25+
args: [--fix]
26+
- id: ruff-format
27+
types_or: [python, pyi]
3828

3929
- repo: https://github.com/pre-commit/pygrep-hooks
4030
rev: v1.10.0
4131
hooks:
4232
- id: rst-backticks
43-
44-
- repo: https://github.com/PyCQA/isort
45-
rev: 9.0.0a3
46-
hooks:
47-
- id: isort
48-
49-
- repo: https://github.com/asottile/pyupgrade
50-
rev: v3.21.2
51-
hooks:
52-
- id: pyupgrade
53-
args: [--py39-plus]
54-
55-
- repo: https://github.com/asottile/setup-cfg-fmt
56-
rev: v3.2.0
57-
hooks:
58-
- id: setup-cfg-fmt

.readthedocs.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
# Required
66
version: 2
77

8-
# Build documentation in the docs/ directory with Sphinx
98
sphinx:
109
configuration: docs/conf.py
1110

12-
# conda:
13-
# environment: docs/environment.yaml
1411
build:
15-
os: ubuntu-22.04
12+
os: ubuntu-lts-latest
1613
tools:
17-
python: "3.11"
14+
python: "3.13"
1815

1916
python:
2017
install:
21-
- method: pip
22-
path: .
23-
extra_requirements:
18+
- method: uv
19+
command: sync
20+
groups:
2421
- docs

AGENTS.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# AGENTS
2+
3+
## Scope
4+
5+
- Keep changes tightly scoped to the requested task.
6+
- Do not rewrite scientific logic or numerical behavior unless the task explicitly requires it.
7+
- Avoid touching generated artifacts in `docs/_build/`, `build/`, or `src/matvis.egg-info/` unless explicitly asked.
8+
9+
10+
## Do
11+
- use uv run for all project tooling commands (pytest, ruff, etc.)
12+
- setup environment with uv sync; prefer uv sync --locked --all-extras --dev for CI parity
13+
- add type hints for all new parameters
14+
- write or update tests for every behavior change
15+
- add numpydoc-style docstrings for new public modules, classes, and functions
16+
- update docstrings whenever parameters are added or changed
17+
- prefer minimal, file-scoped checks before broad checks
18+
19+
## Do not
20+
- do not edit CHANGELOG.rst unless explicitly asked
21+
- do not modify regression artifacts or data snapshots unless explicitly asked
22+
- do not run full test suites or expensive notebook/doc executions without approval
23+
- do not introduce API-breaking renames or default changes without explicit confirmation
24+
25+
### Commands
26+
27+
#### File-scoped quality checks (preferred)
28+
uv run ruff format path/to/file.py
29+
uv run ruff check --fix path/to/file.py
30+
31+
#### Targeted tests (preferred)
32+
uv run pytest tests/path/to/test_file.py
33+
uv run pytest tests/path/to/test_file.py -k keyword
34+
35+
#### Wider checks (ask first)
36+
uv run prek run -a
37+
uv run pytest
38+
39+
### Safety and permissions
40+
41+
Allowed without prompt:
42+
- read, list, and search files
43+
- edit source, tests, and docs text files relevant to the task
44+
- run file-scoped ruff checks
45+
- run one or a few targeted pytest files
46+
47+
Ask first:
48+
- package or environment installs/upgrades
49+
- full-suite pytest runs
50+
- notebook execution across docs/examples
51+
- regenerating regression data
52+
- deleting files, chmod, git push
53+
54+
### Testing expectations
55+
56+
- bug fixes should include regression tests
57+
- use explicit numeric tolerances for floating-point comparisons
58+
- handle warnings intentionally (fix or filter in tests)
59+
60+
### API docs
61+
62+
- docs are built with sphinx and numpydoc
63+
- keep API docs indexed in docs/api.rst when adding new public objects
64+
65+
### Process note
66+
67+
- branch/release docs and workflows may differ historically; do not assume release branching strategy unless user specifies
68+
69+
### PR checklist
70+
71+
- formatting and lint checks pass
72+
- unit tests pass
73+
- tests added for new or changed behavior
74+
75+
### When stuck
76+
77+
- ask a clarifying question
78+
- propose a short plan with assumptions
79+
- provide a minimal draft patch with explicit unknowns
80+
81+
### Test-first mode
82+
83+
- for new features, write or update tests first, then code to green
84+
85+
## GPU CI Constraints
86+
87+
- Treat the self-hosted GPU runner as environment-sensitive infrastructure.
88+
- Keep the existing micromamba activation flow unless the user explicitly asks to replace it.
89+
- Prefer replacing `pip` usage with `uv` usage inside the existing GPU environment rather than redesigning the runner.

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ matvis
77
:target: https://badge.fury.io/py/vis-cpu
88
.. image:: https://codecov.io/gh/hera-team/ matvis/branch/main/graph/badge.svg
99
:target: https://codecov.io/gh/hera-team/ matvis
10-
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
11-
:target: https://github.com/psf/black
10+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
11+
:target: https://github.com/astral-sh/ruff
1212

1313

1414
Fast matrix-based visibility simulator capable of running on CPU and GPU.

gpu-analysis.nvprof

-416 KB
Binary file not shown.

pyproject.toml

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,127 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
2+
requires = ["setuptools>=77", "setuptools_scm[toml]>=8"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "matvis"
7+
description = "Fast matrix-based visibility simulator with interface to CPU and GPU"
8+
readme = { file = "README.rst", content-type = "text/x-rst" }
9+
requires-python = ">=3.11"
10+
license = "MIT"
11+
license-files = ["LICENSE.txt"]
12+
authors = [{ name = "HERA-Team", email = "steven.g.murray@asu.edu" }]
13+
classifiers = [
14+
"Development Status :: 4 - Beta",
15+
"Programming Language :: Python",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3 :: Only",
18+
]
19+
dynamic = ["version"]
20+
dependencies = [
21+
"astropy",
22+
"click",
23+
"docstring-parser",
24+
"line-profiler",
25+
"numpy>=2.0",
26+
"psutil",
27+
"pyuvdata>=3.2.0",
28+
"rich",
29+
"scipy",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/hera-team/matvis"
34+
35+
[project.scripts]
36+
matvis = "matvis.cli:main"
37+
38+
[project.optional-dependencies]
39+
gpu = [
40+
"cupy",
41+
"jinja2",
42+
]
43+
profile = [
44+
"click",
45+
"line-profiler",
46+
"pyuvsim>=1.2.5",
47+
]
48+
49+
[dependency-groups]
50+
docs = [
51+
"furo",
52+
"ipython",
53+
"nbsphinx",
54+
"numpydoc",
55+
"sphinx",
56+
57+
]
58+
doctests = [
59+
"ipykernel>=7.2.0",
60+
"jupyter>=1.1.1",
61+
"matplotlib>=3.8.0",
62+
"papermill>=2.7.0",
63+
]
64+
65+
test = [
66+
"astropy-healpix",
67+
"hypothesis",
68+
"ipython",
69+
"matplotlib",
70+
"pyradiosky",
71+
"pytest",
72+
"pytest-cov",
73+
"pytest-lazy-fixtures",
74+
"pyuvsim[sim]>=1.2.5",
75+
]
76+
dev = [
77+
{ include-group = "docs" },
78+
{ include-group = "test" },
79+
{ include-group = "doctests" },
80+
"prek",
81+
"ruff",
82+
]
83+
84+
[tool.setuptools]
85+
include-package-data = true
86+
zip-safe = false
87+
88+
[tool.setuptools.package-dir]
89+
"" = "src"
90+
91+
[tool.setuptools.packages.find]
92+
where = ["src"]
93+
exclude = ["tests"]
94+
namespaces = true
95+
96+
[tool.pytest.ini_options]
97+
addopts = ["--cov=matvis", "--cov-report=term-missing", "--verbose"]
98+
norecursedirs = ["dist", "build", ".tox"]
99+
testpaths = ["tests"]
100+
101+
[tool.ruff]
102+
line-length = 88
103+
extend-exclude = [
104+
"build",
105+
"dist",
106+
".eggs",
107+
".tox",
108+
"docs/_build",
109+
"docs/conf.py",
110+
"src/matvis/data",
111+
]
112+
113+
[tool.ruff.lint]
114+
select = ["A", "B", "C4", "C90", "D", "E", "F", "G", "I", "T20", "UP", "W"]
115+
ignore = ["B007", "D107", "D401", "D404", "E203", "E231", "E266", "E501", "F401", "F403", "G004"]
116+
per-file-ignores = { "src/matvis/cli.py" = ["T20"], "tests/*.py" = ["E402", "T20"] }
117+
118+
[tool.ruff.lint.mccabe]
119+
max-complexity = 25
120+
121+
[tool.ruff.lint.pydocstyle]
122+
convention = "numpy"
123+
124+
[tool.ruff.format]
125+
docstring-code-format = true
126+
5127
[tool.setuptools_scm]

0 commit comments

Comments
 (0)