Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dc669c7
Migrate project infrastructure to Poetry
sethrj May 7, 2026
17ad651
Increase max file size for large poetry lock files
sethrj May 7, 2026
336ddd7
Update version and superficialities
sethrj May 7, 2026
0ef8fff
Remove python version requirement
sethrj May 7, 2026
0c2347b
Remove lockfile
sethrj May 7, 2026
696c149
Restore precommit max size
sethrj May 7, 2026
43d67c9
Apply suggestions from code review
sethrj May 7, 2026
6d17b42
Update readme
sethrj May 7, 2026
43889ef
Update readme and require py3.11 due to StrEnum
sethrj May 7, 2026
1d42a7e
Use dynamic versioning
sethrj May 7, 2026
3102eb2
Add repo setup action and use poetry 2.x
sethrj May 28, 2026
0db1719
Update action
sethrj May 28, 2026
32d3090
Delete pypi for now
sethrj May 28, 2026
d7a3b60
Remove unused docs for now
sethrj May 28, 2026
4e96d6a
Actually use python version
sethrj May 28, 2026
9e8feb5
Update action: correct version, new cache, use string
sethrj May 28, 2026
23cd613
Update dependencies
sethrj May 28, 2026
df50be6
Address feedback
sethrj May 28, 2026
e7f9077
fixup! Update dependencies
sethrj May 28, 2026
4acd30c
use tomlsort commit hook instead of makefile
sethrj May 28, 2026
c641bf9
Remove pytest pre-commit hook
sethrj May 28, 2026
d3b4c8d
Use pre-commit hooks and do not do full test suite on commit
sethrj May 29, 2026
ebcc5b3
Update lockfile caching, use ruff only for pre-commit
sethrj May 29, 2026
d8acc9a
Merge remote-tracking branch 'upstream/main' into poetry
sethrj May 29, 2026
d709e37
Manually install poetry and fix lock title
sethrj May 29, 2026
be8f5f1
Fix poetry path
sethrj May 29, 2026
a7b8231
Use project instead of tool.poetry
sethrj May 29, 2026
595517f
Add verbosity and fix poetry config command
sethrj May 29, 2026
1853955
Fix dev dependencies
sethrj May 29, 2026
406f7e2
Update dependencies and make more verbose
sethrj May 29, 2026
edcb580
Update poetry version and remove included dep
sethrj May 29, 2026
064bd2b
Clean action
sethrj May 29, 2026
31b08af
Add poetry lockfile to repository
sethrj May 29, 2026
3c99032
Address comments, update readme and workflow
sethrj May 29, 2026
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
46 changes: 46 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Setup the dependencies
description: Check out the repo, install pinned Python and Poetry version, make deps

inputs:
python-version:
description: Python version to install
required: false
default: "3.11"
poetry-version:
description: Poetry version to install
required: false
default: "2.3.3"

runs:
using: composite
steps:
- name: Install python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Install poetry
id: setup-poetry
shell: sh
run: |
printf "\033[34;1m%s\033[0m: %s\n" "Python location" "$(command -v python)"
pipx install --python python poetry==${{ inputs.poetry-version }}
printf "\033[34;1m%s\033[0m: %s\n" "Poetry location" "$(command -v poetry)"
# Configure dependencies to install in venv
poetry config --no-interaction virtualenvs.create true
poetry config --no-interaction virtualenvs.in-project true
- name: Cache venv for OS, python, lockfile
id: cached-venv
uses: actions/cache@v5
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies when uncached
if: ${{steps.cached-venv.outputs.cache-hit != 'true'}} # inexact = false
shell: sh
run: poetry -v install --no-interaction --no-root --with test --without dev
- name: Install project
shell: sh
run: poetry -v install --no-interaction --only-root

# vim: set nowrap tw=100:
23 changes: 12 additions & 11 deletions .github/workflows/lockfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- uses: actions/setup-python@v5
with:
python-version-file: .python-version
- uses: ./.github/actions/setup-poetry

- name: "Update Lockfiles and Open PR"
uses: tedivm/action-python-lockfile-update@v2
with:
pip_extras: "dev"
# This key will bypass workflow limitations to ensure tests are run.
# deploy_key: ${{ secrets.WRITEABLE_DEPLOY_KEY }}
- name: Update Lockfile
run: poetry update
Comment thread
sethrj marked this conversation as resolved.

- name: Open PR with updated lockfile
uses: peter-evans/create-pull-request@v7
with:
commit-message: "Update poetry.lock"
branch: chore/update-lockfile
title: "Update poetry.lock"
body: "Automated dependency update via `poetry update`."
delete-branch: true
env:
# Needed to open pull request- automatically set for all actions.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ concurrency:
cancel-in-progress: true

jobs:
pypi:
uses: ./.github/workflows/pypi.yml
# doc:
# uses: ./.github/workflows/doc.yml
test:
uses: ./.github/workflows/test.yml
# doc:
# uses: ./.github/workflows/doc.yml
all:
needs: [pypi]
needs: [test]
Comment thread
sethrj marked this conversation as resolved.
runs-on: ubuntu-latest
steps:
- name: Success
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/pypi.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@ env:

jobs:
test:
name: ${{matrix.target}}
name: ${{matrix.python-version}}/${{matrix.target}}
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
target:
- black
- mypy
- pytest
- ruff
- tomlsort
include:
- target: pytest-cov
python-version: "3.14"

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: "Checkout repo"
uses: actions/checkout@v5
- name: "Set up dependencies and install"
uses: ./.github/actions/setup-poetry
with:
python-version-file: .python-version
- name: Install Dependencies
run: make install
python-version: ${{matrix.python-version}}
- name: Test
run: make test/${{matrix.target}}

Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ ipython_config.py
# install all needed dependencies.
Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ repos:
hooks:
- id: check-added-large-files
args: ['--maxkb=100']
exclude: '^poetry.lock$'
- id: check-case-conflict
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

70 changes: 30 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,35 @@ postprocessing utilities.

# Development

Development is a little weird if you're not used to modern python projects,
especially because [python development and packaging evolves so
quickly](https://dev.to/farcellier/i-migrate-to-poetry-in-2023-am-i-right--115).
To isolate the development environment, `pyenv` and `pip`
install a toolchain locally.

## Setting up

External dependencies (easily installed through [Homebrew](https://brew.sh/) or
another package manager):
- [pyenv](https://github.com/pyenv/pyenv), which will install its own python versions in an isolated environment

After cloning the repository, run `make pre-commit` to:
- Install the development version of python specified in `.python-version` to
your `pyenv` prefix (default: `~/.pyenv`, configurable with the `PYENV_ROOT`
variable)
- Set up a virtual environment in `.venv` that will contain all the development
dependencies, including a `celerpy` symlink in its environment that will
point to your working copy
- Install pre-commit hooks that use the tools just installed in your virtual
environment.

## Testing and committing

At this point you can modify the python code and run tests *without* having to
reinstall the dependencies, and every `git commit` will run the tests
automatically. (Use `git commit --no-verify` to disable.)

The makefile specifies a few useful targets:
- `style`: apply style fixups to all the python files in development
- `test`: run tests
- `pip`: reinstall all the dependencies in your virtual environment
- `rebuild_dependencies`: update the `requirements` file if you add a new
dependency to `pyproject.toml`

You can also test independently once your virtual environment is set up. For
example, to run a single python test function from a single python test, with
the most verbose output and sending stdout/stderr to the console, run:
To isolate the development environment, this project uses
[Poetry](https://python-poetry.org/) to manage dependencies, virtual
environments, and lockfiles. A persistent development+CI environment is encoded
into the distributed `poetry.lock` file. A simple `makefile` is included to
configure and run for those not familiar with a Poetry envirnment workflow.

## Setting up the first time

Install Poetry using [Homebrew](https://brew.sh/) or [pipx](https://pipx.pypa.io/stable/how-to/install-pipx/).

After cloning the celerpy repository and installing poetry, run `make setup` to:
- install all project and development dependencies from `poetry.lock`, and
- install pre-commit hooks.

## Development and testing

Activating the poetry environment will load the python version and all development dependencies. It is faster than manually invoking `poetry run` or using the included makefile.

```console
$ . .venv/bin/activate
$ pytest -vv -s test/test_process.py -k test_context
$ eval $(poetry env activate)
$ pytest test/
$ mypy celerpy
$ poetry run pytest -vv -s test/test_process.py -k test_context
```

## Pre-commit hooks

Style and linting should be performed automatically at every `git commit` after you run `make pre-commit`. They can also be invoked manually with `pre-commit run`. Use `git commit --no-verify` to disable temporarily for a particular commit. Pull requests automatically have their style checked and fixed via `pre-commit.ci`.

## Release/versioning

Not yet implemented:
8 changes: 4 additions & 4 deletions celerpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
# See the top-level LICENSE file for details.
# SPDX-License-Identifier: Apache-2.0
try:
from . import _version # type: ignore[attr-defined]
from importlib.metadata import PackageNotFoundError, version

__version__ = _version.__version__
except: # noqa: E722
try:
__version__ = version("celerpy")
except PackageNotFoundError:
__version__ = "0.0.0-dev"

# Expose __version__ for type checkers
Expand Down
4 changes: 2 additions & 2 deletions celerpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def load_settings():

def print_version(value: bool):
if value:
from . import _version
from . import __version__

typer.echo(_version.version)
typer.echo(__version__)
raise typer.Exit()


Expand Down
6 changes: 3 additions & 3 deletions celerpy/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WrappingListedColormap(ListedColormap):
through the available colors and emit a warning.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._warned: bool = False

Expand Down Expand Up @@ -87,8 +87,8 @@ class IdMapper:
(so that new volumes "appear").
"""

def __init__(self):
self.id_to_volume = []
def __init__(self) -> None:
self.id_to_volume: list[str] = []
self.volume_to_id = ReverseIndexDict(self.id_to_volume)

def clear(self):
Expand Down
8 changes: 0 additions & 8 deletions doc/dev/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions doc/dev/cli.md

This file was deleted.

1 change: 0 additions & 1 deletion doc/dev/dependencies.md

This file was deleted.

1 change: 0 additions & 1 deletion doc/dev/github.md

This file was deleted.

1 change: 0 additions & 1 deletion doc/dev/pypi.md

This file was deleted.

3 changes: 0 additions & 3 deletions doc/dev/settings.md

This file was deleted.

Loading