Skip to content

Commit

Permalink
Merge pull request #240 from MPoL-dev/pyproject
Browse files Browse the repository at this point in the history
Switch to pyproject and hatch build
  • Loading branch information
iancze authored Dec 23, 2023
2 parents 16cfc3e + 65f3731 commit bd43100
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 122 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,9 @@ dirty_image_model.pt
# setup file
project_setup.sh

# likely folders from testing
plotsdir
runs

# hatch-generated version file
src/mpol/mpol_version.py
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

## v0.2.1

- Fully leaned into the `pyproject.toml` setup to modernize build via [hatch](https://github.com/pypa/hatch). This centralizes the project dependencies and derives package versioning directly from git tags. Intermediate packages built from commits after the latest tag (e.g., `0.2.0`) will have an extra long string, e.g., `0.2.1.dev178+g16cfc3e.d20231223` where the version is a guess at the next version and the hash gives reference to the commit. This means that developers bump versions entirely by tagging a new version with git (or more likely by drafting a new release on the [GitHub release page](https://github.com/MPoL-dev/MPoL/releases)).
- Removed `setup.py`.
- TOML does not support adding keyed entries, so creating layered build environments of default, `docs`, `test`, and `dev` as we used to with `setup.py` is laborious and repetitive with `pyproject.toml`. We have simplified the list to be default (key dependencies), `test` (minimal necessary for test-suite), and `dev` (covering everything needed to build the docs and actively develop the package).
- Removed custom `spheroidal_gridding` routines, tests, and the `UVDataset` object that used them. These have been superseded by the TorchKbNuFFT package. For reference, the old routines (including the tricky `corrfun` math) is preserved in a Gist [here](https://gist.github.com/iancze/f3d2769005a9e2c6731ee6977f166a83).
- Changed API of {class}`~mpol.fourier.NuFFT`. Previous signature took `uu` and `vv` points at initialization (`__init__`), and the `.forward` method took only an image cube. This behaviour is preserved in a new class {class}`~mpol.fourier.NuFFTCached`. The updated signature of {class}`~mpol.fourier.NuFFT` *does not* take `uu` and `vv` at initialization. Rather, its `forward` method is modified to take an image cube and the `uu` and `vv` points. This allows an instance of this class to be used with new `uu` and `vv` points in each forward call. This follows the standard expectation of a layer (e.g., a linear regression function predicting at new `x`) and the pattern of the TorchKbNuFFT package itself. It is expected that the new `NuFFT` will be the default routine and `NuFFTCached` will only be used in specialized circumstances (and possibly deprecated/removed in future updates). Changes implemented by [#232](https://github.com/MPoL-dev/MPoL/pull/232).
- Moved "Releasing a new version of MPoL" from the wiki to the Developer Documentation ({ref}`releasing-new-version-label`).
Expand Down
35 changes: 16 additions & 19 deletions docs/developer-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ git fetch --tags
git checkout tags/v0.2.0
```

Otherwise, proceed directly with installing the build dependencies for the documentation with
Otherwise, proceed directly with installing the development dependencies
```
$ pip install ".[docs]"
$ pip install ".[dev]"
```

Alternatively, you could start from `[dev]` list, since it is a superset of `[docs]`.

### Building the Documentation

To build the documentation, change to the `docs/` folder and run
Expand Down Expand Up @@ -202,7 +200,7 @@ To write a tutorial, we suggest copying and rename one of the existing `.md` fil

When done, add a reference to your tutorial in the table of contents in `docs/index.rst`. E.g., if your contribution is the `ci-tutorials/gridder.md` file, add a `ci-tutorials/gridder.md` line. Then, you should be able to build the documentation as normal (i.e., `make html`) and your tutorial will be included in the documentation. The MyST-NB plugin is doing the work behind the scenes.

If your tutorial requires any extra build dependencies, please add them to the `EXTRA_REQUIRES['docs']` list in `setup.py`.
If your tutorial requires any extra build dependencies, please add them to the `[project.optional-dependencies]["dev"]` list in `pyproject.toml`.

#### Larger tutorials requiring substantial computational resources

Expand Down Expand Up @@ -231,19 +229,18 @@ If you're thinking about contributing a tutorial and would like guidance on form
(releasing-new-version-label)=
## Releasing a new version of MPoL

To release a new version of MPoL, follow these steps in order:
To release a new version of MPoL, follow this checklist in order:

1. Ensure all tests are passing on your PR
* If tests are passing locally and failing in the GitHub Actions workflows, compare the code dependencies in `setup.py` with your local versions
2. Ensure the docs build locally without errors or warnings
3. Update the code version in `__init__`
4. Update the version history in `changelog.md`
5. Update the contributors in `CONTRIBUTORS.md`
6. Update the copyright year and citation in `README.md`
1. Ensure *all* tests are passing on your PR, both locally and via GitHub Actions.
* If tests pass locally but fail in the GitHub Actions workflows, inspect the GitHub Actions workflow logs for clues about missing packages or outdated dependencies.
2. Ensure the docs build locally without errors or warnings. Check output by opening `docs/_build/html/index.html` with your web browser.
3. Perform final round of edits documenting the changes since last version in `changelog.md`. If any changes are potentially breaking, suggest how users might change their workflow to incorporate updates.
4. Check contributors in `CONTRIBUTORS.md` up to date.
5. Update the copyright year and citation in `README.md`
* In the citation, update all fields except 'Zenodo', 'doi', and 'url' (the current DOI will cite all versions and the URL will direct to the most recent version)
7. Merge your PR into `main`
* Ensure all tests triggered by the merge pass
8. Publish a pre-release
* Ensure the `pre-release.yml` workflow passes
9. Publish a (true) release, which will be automatically uploaded to PyPI and archived on Zenodo
* Verify this by ensuring the `package.yml` workflow passes
6. Merge your PR into `main` using the GitHub interface.
* A new round of tests will be triggered by the merge. Make sure *all* of these pass.
7. Go to the [Releases](https://github.com/MPoL-dev/MPoL/releases) page, draft release notes, and publish a pre-release
* Ensure the `pre-release.yml` workflow passes.
8. Publish the true release. GitHub actions will automatically uploaded the built package to PyPI and archive it on Zenodo
* Verify this has worked by checking the `package.yml` workflow passed.
73 changes: 71 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]

[project]
authors = [{ name = "Ian Czekala", email = "[email protected]" }]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"numpy",
"fast-histogram",
"scipy",
"torch>=1.8.0",
"torchvision",
"torchaudio",
"torchkbnufft",
"astropy",
]
description = "Regularized Maximum Likelihood Imaging for Radio Astronomy"
dynamic = ["version"]
name = "MPoL"
readme = "README.md"
requires-python = ">3.8"

[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
"matplotlib",
"requests",
"astropy",
"tensorboard",
"mypy",
"frank>=1.2.1",
"sphinx>=5.3.0",
"jupytext",
"ipython!=8.7.0", # broken version for syntax higlight https://github.com/spatialaudio/nbsphinx/issues/687
"nbsphinx",
"sphinx_book_theme>=0.9.3",
"sphinx_copybutton",
"jupyter",
"nbconvert",
"sphinxcontrib-mermaid>=0.8.1",
"myst-nb",
"jupyter-cache",
"Pillow",
"asdf",
"pyro-ppl",
"arviz[all]",
]
test = [
"pytest",
"pytest-cov",
"matplotlib",
"requests",
"tensorboard",
"mypy",
"frank>=1.2.1",
]

[project.urls]
Homepage = "https://mpol-dev.github.io/MPoL/"
Issues = "https://github.com/MPoL-dev/MPoL/issues"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/mpol/mpol_version.py"
99 changes: 0 additions & 99 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/mpol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.2.1"
zenodo_record = 10064221
from mpol.mpol_version import __version__
zenodo_record = 10064221

0 comments on commit bd43100

Please sign in to comment.