Skip to content

Commit 4e5d0ab

Browse files
timmensclaude
andcommitted
Migrate from conda/micromamba to pixi for environment management
Replace conda environment.yml files and micromamba-based CI with pixi configuration embedded in pyproject.toml. This simplifies environment management by using a single source of truth for all dependencies. - Add [tool.pixi.*] sections to pyproject.toml with all environments - Rewrite CI workflow to use prefix-dev/setup-pixi - Update .readthedocs.yml to use pixi via asdf - Remove old conda files (environment.yml, testenv-*.yml, update_envs.py) - Update check_mypy_versions.py to read from pyproject.toml - Update developer docs to reference pixi commands - Bump check-added-large-files maxkb to accommodate pixi.lock Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a4c2d3 commit 4e5d0ab

19 files changed

Lines changed: 34035 additions & 745 deletions

.github/workflows/main.yml

Lines changed: 97 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
name: main
3-
# Automatically cancel a previous run.
43
concurrency:
54
group: ${{ github.head_ref || github.run_id }}
65
cancel-in-progress: true
@@ -13,39 +12,35 @@ on:
1312
- '*'
1413
jobs:
1514
run-tests-linux:
16-
name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
17-
runs-on: ${{ matrix.os }}
15+
name: Run tests on ubuntu-latest py${{ matrix.python-version }}
16+
runs-on: ubuntu-latest
1817
strategy:
1918
fail-fast: false
2019
matrix:
21-
os:
22-
- ubuntu-latest
2320
python-version:
24-
- '3.10'
25-
- '3.11'
26-
- '3.12'
27-
- '3.13'
21+
- '310'
22+
- '311'
23+
- '312'
24+
- '313'
2825
steps:
2926
- uses: actions/checkout@v4
30-
- name: create build environment
31-
uses: mamba-org/setup-micromamba@v1
27+
- uses: prefix-dev/setup-pixi@v0.9.4
3228
with:
33-
environment-file: ./.tools/envs/testenv-linux.yml
34-
cache-environment: true
35-
create-args: |
36-
python=${{ matrix.python-version }}
37-
- name: run pytest
38-
shell: bash -l {0}
39-
run: |
40-
micromamba activate optimagic
41-
pytest --cov-report=xml --cov=./
29+
pixi-version: v0.65.0
30+
cache: true
31+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
32+
frozen: true
33+
environments: test-linux-py${{ matrix.python-version }}
34+
- name: Run pytest
35+
shell: bash -el {0}
36+
run: pixi run -e test-linux-py${{ matrix.python-version }} tests-with-cov
4237
- name: Upload coverage report.
43-
if: runner.os == 'Linux' && matrix.python-version == '3.10'
38+
if: matrix.python-version == '310'
4439
uses: codecov/codecov-action@v4
4540
with:
4641
token: ${{ secrets.CODECOV_TOKEN }}
4742
run-tests-win-and-mac:
48-
name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
43+
name: Run tests on ${{ matrix.os }} py${{ matrix.python-version }}
4944
runs-on: ${{ matrix.os }}
5045
strategy:
5146
fail-fast: false
@@ -54,163 +49,121 @@ jobs:
5449
- macos-latest
5550
- windows-latest
5651
python-version:
57-
- '3.10'
58-
- '3.11'
59-
- '3.12'
60-
- '3.13'
52+
- '310'
53+
- '311'
54+
- '312'
55+
- '313'
6156
steps:
6257
- uses: actions/checkout@v4
63-
- name: create build environment
64-
uses: mamba-org/setup-micromamba@v1
58+
- uses: prefix-dev/setup-pixi@v0.9.4
6559
with:
66-
micromamba-version: 1.5.6-0
67-
environment-file: ./.tools/envs/testenv-others.yml
68-
cache-environment: true
69-
create-args: |
70-
python=${{ matrix.python-version }}
71-
- name: run pytest
72-
shell: bash -l {0}
73-
run: |
74-
micromamba activate optimagic
75-
pytest -m "not slow and not jax"
60+
pixi-version: v0.65.0
61+
cache: true
62+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
63+
frozen: true
64+
environments: test-py${{ matrix.python-version }}
65+
- name: Run pytest
66+
shell: bash -el {0}
67+
run: pixi run -e test-py${{ matrix.python-version }} tests-fast
7668
run-tests-with-old-pandas:
77-
# This job is only for testing if optimagic works with pandas<2, as many pandas
78-
# functions we use will be deprecated in pandas 3. optimagic's behavior for older
79-
# verions is handled in src/optimagic/compat.py. For compatibility with we have to
80-
# restrict numpy<2.
81-
name: Run tests for ${{ matrix.os}} on ${{ matrix.python-version }} with pandas 1
82-
runs-on: ${{ matrix.os }}
83-
strategy:
84-
fail-fast: false
85-
matrix:
86-
os:
87-
- ubuntu-latest
88-
python-version:
89-
- '3.10'
69+
name: Run tests on ubuntu-latest with pandas < 2
70+
runs-on: ubuntu-latest
9071
steps:
9172
- uses: actions/checkout@v4
92-
- name: create build environment
93-
uses: mamba-org/setup-micromamba@v1
73+
- uses: prefix-dev/setup-pixi@v0.9.4
9474
with:
95-
environment-file: ./.tools/envs/testenv-pandas.yml
96-
cache-environment: true
97-
create-args: |
98-
python=${{ matrix.python-version }}
99-
- name: run pytest
100-
shell: bash -l {0}
101-
run: |
102-
micromamba activate optimagic
103-
pytest -m "not slow and not jax"
75+
pixi-version: v0.65.0
76+
cache: true
77+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
78+
frozen: true
79+
environments: test-old-pandas
80+
- name: Run pytest
81+
shell: bash -el {0}
82+
run: pixi run -e test-old-pandas tests-fast
10483
run-tests-with-old-numpy:
105-
# This job is only for testing if optimagic works with numpy<2. Because we already
106-
# test pandas<2 with numpy<2, in this environment we restrict pandas>=2.
107-
name: Run tests for ${{ matrix.os}} on ${{ matrix.python-version }} with numpy 1
108-
runs-on: ${{ matrix.os }}
109-
strategy:
110-
fail-fast: false
111-
matrix:
112-
os:
113-
- ubuntu-latest
114-
python-version:
115-
- '3.10'
84+
name: Run tests on ubuntu-latest with numpy < 2
85+
runs-on: ubuntu-latest
11686
steps:
11787
- uses: actions/checkout@v4
118-
- name: create build environment
119-
uses: mamba-org/setup-micromamba@v1
88+
- uses: prefix-dev/setup-pixi@v0.9.4
12089
with:
121-
environment-file: ./.tools/envs/testenv-numpy.yml
122-
cache-environment: true
123-
create-args: |
124-
python=${{ matrix.python-version }}
125-
- name: run pytest
126-
shell: bash -l {0}
127-
run: |
128-
micromamba activate optimagic
129-
pytest -m "not slow and not jax"
90+
pixi-version: v0.65.0
91+
cache: true
92+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
93+
frozen: true
94+
environments: test-old-numpy
95+
- name: Run pytest
96+
shell: bash -el {0}
97+
run: pixi run -e test-old-numpy tests-fast
13098
run-tests-with-old-plotly:
131-
name: Run tests for ubuntu-latest on 3.10 with plotly < 6 and kaleido < 0.3
99+
name: Run tests on ubuntu-latest with plotly < 6
132100
runs-on: ubuntu-latest
133-
strategy:
134-
fail-fast: false
135101
steps:
136102
- uses: actions/checkout@v4
137-
- name: create build environment
138-
uses: mamba-org/setup-micromamba@v1
103+
- uses: prefix-dev/setup-pixi@v0.9.4
139104
with:
140-
environment-file: ./.tools/envs/testenv-plotly.yml
141-
cache-environment: true
142-
create-args: |
143-
python=3.10
144-
- name: run pytest
145-
shell: bash -l {0}
146-
run: |
147-
micromamba activate optimagic
148-
pytest -m "not slow and not jax"
105+
pixi-version: v0.65.0
106+
cache: true
107+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
108+
frozen: true
109+
environments: test-old-plotly
110+
- name: Run pytest
111+
shell: bash -el {0}
112+
run: pixi run -e test-old-plotly tests-fast
149113
run-tests-nevergrad:
150-
# This job is for running test related to nevergrad with pinned version of
151-
# bayesian_optimization == 1.4.0
152-
name: Run tests for ubuntu-latest on ${{ matrix.python-version }} bayes_opt==1.4.0
153-
runs-on: ${{ matrix.os }}
114+
name: Run nevergrad tests py${{ matrix.python-version }}
115+
runs-on: ubuntu-latest
154116
strategy:
155117
fail-fast: false
156118
matrix:
157-
os:
158-
- ubuntu-latest
159119
python-version:
160-
- '3.10'
161-
- '3.11'
162-
- '3.12'
163-
- '3.13'
120+
- '310'
121+
- '311'
122+
- '312'
123+
- '313'
164124
steps:
165125
- uses: actions/checkout@v4
166-
- name: create build environment
167-
uses: mamba-org/setup-micromamba@v1
126+
- uses: prefix-dev/setup-pixi@v0.9.4
168127
with:
169-
environment-file: ./.tools/envs/testenv-nevergrad.yml
170-
cache-environment: true
171-
create-args: |
172-
python=${{ matrix.python-version }}
173-
- name: run pytest
174-
shell: bash -l {0}
175-
run: |
176-
micromamba activate optimagic
128+
pixi-version: v0.65.0
129+
cache: true
130+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
131+
frozen: true
132+
environments: test-nevergrad-py${{ matrix.python-version }}
133+
- name: Run pytest
134+
shell: bash -el {0}
135+
run: >-
136+
pixi run -e test-nevergrad-py${{ matrix.python-version }}
177137
pytest tests/optimagic/optimizers/test_nevergrad.py
178138
code-in-docs:
179139
name: Run code snippets in documentation
180140
runs-on: ubuntu-latest
181141
steps:
182142
- uses: actions/checkout@v4
183-
- name: create build environment
184-
uses: mamba-org/setup-micromamba@v1
143+
- uses: prefix-dev/setup-pixi@v0.9.4
185144
with:
186-
environment-file: ./.tools/envs/testenv-linux.yml
187-
environment-name: optimagic
188-
cache-environment: true
189-
create-args: |
190-
python=3.12
191-
- name: run sphinx
192-
shell: bash -l {0}
193-
run: |-
194-
micromamba activate optimagic
195-
cd docs/source
196-
python -m doctest -v how_to/how_to_constraints.md
145+
pixi-version: v0.65.0
146+
cache: true
147+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
148+
frozen: true
149+
environments: test-linux-py312
150+
- name: Run doctest
151+
shell: bash -el {0}
152+
run: >-
153+
pixi run -e test-linux-py312
154+
python -m doctest -v docs/source/how_to/how_to_constraints.md
197155
run-mypy:
198156
name: Run mypy
199157
runs-on: ubuntu-latest
200-
strategy:
201-
fail-fast: false
202158
steps:
203159
- uses: actions/checkout@v4
204-
- name: create build environment
205-
uses: mamba-org/setup-micromamba@v1
160+
- uses: prefix-dev/setup-pixi@v0.9.4
206161
with:
207-
environment-file: ./.tools/envs/testenv-linux.yml
208-
environment-name: optimagic
209-
cache-environment: true
210-
create-args: |
211-
python=3.10
162+
pixi-version: v0.65.0
163+
cache: true
164+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
165+
frozen: true
166+
environments: test-linux-py310
212167
- name: Run mypy
213-
shell: bash -l {0}
214-
run: |-
215-
micromamba activate optimagic
216-
mypy
168+
shell: bash -el {0}
169+
run: pixi run -e test-linux-py310 mypy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ venv/
104104
ENV/
105105
env.bak/
106106
venv.bak/
107+
.pixi/
107108

108109
# Spyder project settings
109110
.spyderproject

.pre-commit-config.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@ repos:
1010
hooks:
1111
- id: yamlfix
1212
exclude: tests/optimagic/optimizers/_pounders/fixtures
13-
- repo: local
14-
hooks:
15-
- id: update-environment-files
16-
name: check environment file updates
17-
entry: python .tools/update_envs.py
18-
language: python
19-
always_run: true
20-
require_serial: true
2113
- repo: local
2214
hooks:
2315
- id: check-mypy-versions
24-
name: verify that pre-commits and dev env use the same mypy version
16+
name: verify that pre-commits and pixi use the same mypy version
2517
entry: python .tools/check_mypy_versions.py
2618
language: python
2719
always_run: true
@@ -44,7 +36,7 @@ repos:
4436
hooks:
4537
- id: check-added-large-files
4638
args:
47-
- --maxkb=1300
39+
- --maxkb=2500
4840
exclude: tests/optimagic/optimizers/_pounders/fixtures/
4941
- id: check-case-conflict
5042
- id: check-merge-conflict

.readthedocs.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
---
22
version: 2
33
build:
4-
os: ubuntu-22.04
4+
os: ubuntu-24.04
55
tools:
6-
python: mambaforge-4.10
7-
conda:
8-
environment: docs/rtd_environment.yml
6+
python: '3.12'
7+
jobs:
8+
create_environment:
9+
- asdf plugin add pixi
10+
- asdf install pixi latest
11+
- asdf global pixi latest
12+
install:
13+
- pixi install -e docs
14+
build:
15+
- pixi run -e docs docs
16+
post_build:
17+
- mkdir --parents $READTHEDOCS_OUTPUT/html/
18+
- cp -a docs/build/html/. "$READTHEDOCS_OUTPUT/html" && rm -r docs/build
919
sphinx:
10-
builder: html
1120
configuration: docs/source/conf.py
1221
fail_on_warning: false

0 commit comments

Comments
 (0)