feat: Add Pixi workspace to pyproject.toml - #2638
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2638 +/- ##
=======================================
Coverage 98.24% 98.24%
=======================================
Files 65 65
Lines 4220 4220
Branches 464 464
=======================================
Hits 4146 4146
Misses 45 45
Partials 29 29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I've been making heavy use of https://pixi.sh/latest/python/pyproject_toml/#optional-dependencies for this PR and for testing. I'm also realizing from this PR (/ remembering Issue #2622) that Line 67 in 6b690c5 and that there is a native |
a560690 to
5a00bf4
Compare
e6fa7de to
78d2be8
Compare
There was a problem hiding this comment.
This adds a fully conda-package-based Pixi workspace for pyhf, such that the only Python package is pyhf itself:
$ pixi list -e dev | grep pypi
Environment: dev
pyhf 0.7.1.dev336 pypiIt adds a suite of Pixi tasks as well
$ pixi task list
Tasks that can run on this machine:
-----------------------------------
benchmarks, build-docs, build-package, doctest, lint, notebooks, serve, test, test-contrib
Task Description
benchmarks Run the benchmarks
build-docs Build the pyhf documentation website
build-package Build a sdist and wheel
doctest Run the doctest tests
lint Run pre-commit
notebooks Run the test suite for the notebooks
serve Serve the docs website
test Run the test suite on the core library
test-contrib Run the test suite for the contrib moduleand the ability to get a CUDA accelerated jaxlib environment
$ pixi list -e jax-gpu jax
Environment: jax-gpu
Name Version Build Size Kind Source
jax 0.7.2 pyhd8ed1ab_0 1.78 MiB conda https://conda.anaconda.org/conda-forge
jaxlib 0.7.2 cuda129_py313h33cbcf4_202 166.01 MiB conda https://conda.anaconda.org/conda-forge
$ pixi run -e jax-gpu python
Python 3.13.11 | packaged by conda-forge | (main, Dec 6 2025, 11:24:03) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
>>> import pyhf
>>> jax.devices()
[CudaDevice(id=0)]When Pixi is solving it will raise the following warnings
WARN The package `pytest-benchmark==5.2.3` does not have an extra named `histogram`
WARN The package `coverage==7.13.0` does not have an extra named `toml`
WARN The package `pytest-benchmark==5.2.3` does not have an extra named `histogram`
WARN The package `coverage==7.13.0` does not have an extra named `toml`
which can't be avoided as far as I know, given that it is trying to resolve the extras that exist in the test dependency-group
Line 85 in 86c214d
Line 88 in 86c214d
and can't.
| pixi exec python-build --installer uv . && \ | ||
| pixi exec twine check --strict ./dist/* |
There was a problem hiding this comment.
Doing pixi exec here are these are transitory processes that don't need to have their dependencies constrain the rest of the dev environment.
There was a problem hiding this comment.
Why not use package functionalities here with the pixi-build preview?
There was a problem hiding this comment.
Is that faster or more convenient? That seems like more configuration for no clear benefit.
There was a problem hiding this comment.
I've found it to be a little faster in pyhs3.
There was a problem hiding this comment.
Given that for this PR I wanted to get things working and in a single file, and scipp-atlas/pyhs3#145 has shown us that for now we would need to also use pixi.toml I'd prefer to skip this till pixi-build is fully out of preview.
| default = { solve-group = "default" } | ||
| jax = { features = ["jax"], solve-group = "default" } | ||
| jax-cpu = { features = ["jax-cpu"], solve-group = "default" } | ||
| jax-gpu = { features = ["jax-gpu"], solve-group = "gpu" } |
There was a problem hiding this comment.
Add jax-gpu environment so can get a CUDA enabled jaxlib on demand.
|
cc @MoAly98 @ikrommyd given discussion on scikit-hep/coffea#1503 |
|
Note that as you can't specify default environments for tasks yet (c.f. prefix-dev/pixi#5140) when you run pixi run testyou'll be asked to select an environment $ pixi run test
? The task 'test' can be run in multiple environments.
Please select an environment to run the task in: ›
❯ test
dev
Currently the only way to avoid this is to specify the environment at runtime . |
* Add Pixi workspace to pyproject.toml under [tool.pixi] table. * Add Pixi lock file to .gitignore.
a5155b3 to
2885793
Compare
|
cc @kratsg for review. |
| rsync -r ./src/pyhf/schemas ./docs/_build/html/ | ||
| """ | ||
|
|
||
| [tool.pixi.feature.docs.tasks.serve] |
There was a problem hiding this comment.
I would also add a [...tasks.watch] that does sphinx-autobuild --open-browser -n -T -b html docs docs/_build/html which autoreloads when changes are made.
There was a problem hiding this comment.
Done, but in dev environment.
| pixi exec python-build --installer uv . && \ | ||
| pixi exec twine check --strict ./dist/* |
There was a problem hiding this comment.
Why not use package functionalities here with the pixi-build preview?
Technically, you can do this by simply keeping the task to a single environment. There's some clever restructuring one can do if you don't need all envs all at once. |
@kratsg indeed. We probably can try to do extra clever things moving forward, but I might suggest that we postpone until we can reevaluate the |
Description
pyproject.tomlunder[tool.pixi]table.dependencies to build and deploy the docs to the website.
Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: