Skip to content

Commit 75a9fd2

Browse files
authored
Switched from miniconda-setup to micromamba-setup for mypy workflow (#781)
* Switched from miniconda to micromamba for mypy workflow * setup-micromamba for test.yml * Specified environment-name for test.yml * Changed mamba to micromamba for test.yml
1 parent 6857517 commit 75a9fd2

File tree

2 files changed

+81
-90
lines changed

2 files changed

+81
-90
lines changed

.github/workflows/mypy.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,22 @@ jobs:
1010
runs-on: ubuntu-latest
1111
defaults:
1212
run:
13-
shell: bash -l {0}
13+
shell: bash -leo pipefail {0}
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Cache conda
17-
uses: actions/cache@v4
18-
env:
19-
# Increase this value to reset cache if environment.yml has not changed
20-
CACHE_NUMBER: 0
16+
- uses: mamba-org/setup-micromamba@v1
2117
with:
22-
path: ~/conda_pkgs_dir
23-
key: ${{ runner.os }}-py310-conda-${{ env.CACHE_NUMBER }}-${{
24-
hashFiles('environment.yml') }}
25-
- uses: conda-incubator/setup-miniconda@v3
26-
with:
27-
miniforge-variant: Mambaforge
28-
miniforge-version: latest
29-
mamba-version: "*"
30-
activate-environment: pytensor-test
31-
channel-priority: strict
18+
micromamba-version: "latest" # any version from https://github.com/mamba-org/micromamba-releases
3219
environment-file: environment.yml
33-
python-version: "3.10"
34-
use-mamba: true
35-
use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267
36-
- name: Install-pytensor and mypy dependencies
20+
init-shell: bash
21+
cache-environment: true
22+
post-cleanup: "all"
23+
- name: Install pytensor and mypy dependencies
3724
run: |
38-
conda activate pytensor-test
3925
pip install -e .
4026
python --version
27+
shell: micromamba-shell {0}
4128
- name: Run mypy
4229
run: |
43-
conda activate pytensor-test
44-
python ./scripts/run_mypy.py --verbose
30+
python ./scripts/run_mypy.py --verbose
31+
shell: micromamba-shell {0}

.github/workflows/test.yml

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ jobs:
5555
matrix:
5656
python-version: ["3.10", "3.12"]
5757
steps:
58-
- uses: actions/checkout@v4
59-
- uses: actions/setup-python@v5
60-
with:
61-
python-version: ${{ matrix.python-version }}
62-
- uses: pre-commit/[email protected]
58+
- uses: actions/checkout@v4
59+
- uses: actions/setup-python@v5
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
- uses: pre-commit/[email protected]
6363

6464
test_ubuntu:
6565
name: "Test py${{ matrix.python-version }} : fast-compile ${{ matrix.fast-compile }} : float32 ${{ matrix.float32 }} : ${{ matrix.part }}"
@@ -72,8 +72,8 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
python-version: ["3.10", "3.12"]
75-
fast-compile: [0,1]
76-
float32: [0,1]
75+
fast-compile: [0, 1]
76+
float32: [0, 1]
7777
install-numba: [0]
7878
install-jax: [0]
7979
part:
@@ -84,7 +84,7 @@ jobs:
8484
- "tests/tensor/conv"
8585
- "tests/tensor/rewriting"
8686
- "tests/tensor/test_math.py"
87-
- "tests/tensor/test_basic.py tests/tensor/test_inplace.py"
87+
- "tests/tensor/test_basic.py tests/tensor/test_inplace.py"
8888
- "tests/tensor/test_blas.py tests/tensor/test_elemwise.py tests/tensor/test_math_scipy.py"
8989
exclude:
9090
- python-version: "3.10"
@@ -121,11 +121,13 @@ jobs:
121121
with:
122122
fetch-depth: 0
123123
- name: Set up Python ${{ matrix.python-version }}
124-
uses: conda-incubator/setup-miniconda@v3
124+
uses: mamba-org/setup-micromamba@v1
125125
with:
126-
miniforge-variant: Mambaforge
127-
miniforge-version: latest
128-
python-version: ${{ matrix.python-version }}
126+
environment-name: pytensor-test
127+
micromamba-version: "latest"
128+
init-shell: bash
129+
post-cleanup: "all"
130+
create-args: python=${{ matrix.python-version }}
129131

130132
- name: Create matrix id
131133
id: matrix-id
@@ -138,13 +140,13 @@ jobs:
138140
echo "id=$MATRIX_ID" >> $GITHUB_OUTPUT
139141
140142
- name: Install dependencies
141-
shell: bash -l {0}
143+
shell: micromamba-shell {0}
142144
run: |
143-
mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy
144-
if [[ $INSTALL_NUMBA == "1" ]]; then mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; fi
145-
if [[ $INSTALL_JAX == "1" ]]; then mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" jax jaxlib numpyro && pip install tensorflow-probability; fi
145+
micromamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy
146+
if [[ $INSTALL_NUMBA == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; fi
147+
if [[ $INSTALL_JAX == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" jax jaxlib numpyro && pip install tensorflow-probability; fi
146148
pip install -e ./
147-
mamba list && pip freeze
149+
micromamba list && pip freeze
148150
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
149151
python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"'
150152
env:
@@ -153,7 +155,7 @@ jobs:
153155
INSTALL_JAX: ${{ matrix.install-jax }}
154156

155157
- name: Run tests
156-
shell: bash -l {0}
158+
shell: micromamba-shell {0}
157159
run: |
158160
if [[ $FAST_COMPILE == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,mode=FAST_COMPILE; fi
159161
if [[ $FLOAT32 == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,floatX=float32; fi
@@ -175,55 +177,57 @@ jobs:
175177
path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml
176178

177179
benchmarks:
178-
name: "Benchmarks"
179-
needs:
180-
- changes
181-
- style
182-
runs-on: ubuntu-latest
183-
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
184-
strategy:
185-
fail-fast: false
186-
steps:
187-
- uses: actions/checkout@v4
188-
with:
189-
fetch-depth: 0
190-
- name: Set up Python 3.10
191-
uses: conda-incubator/setup-miniconda@v3
192-
with:
193-
miniforge-variant: Mambaforge
194-
miniforge-version: latest
195-
- name: Install dependencies
196-
shell: bash -l {0}
197-
run: |
198-
mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service cython pytest "numba>=0.57" jax jaxlib pytest-benchmark
199-
pip install -e ./
200-
mamba list && pip freeze
201-
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
202-
python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"'
203-
env:
204-
PYTHON_VERSION: 3.10
205-
- name: Download previous benchmark data
206-
uses: actions/cache@v4
207-
with:
208-
path: ./cache
209-
key: ${{ runner.os }}-benchmark
210-
- name: Run benchmarks
211-
shell: bash -l {0}
212-
run: |
213-
export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe
214-
python -m pytest --runslow --benchmark-only --benchmark-json output.json
215-
- name: Store benchmark result
216-
uses: benchmark-action/github-action-benchmark@v1
217-
with:
218-
name: Python Benchmark with pytest-benchmark
219-
tool: 'pytest'
220-
output-file-path: output.json
221-
external-data-json-path: ./cache/benchmark-data.json
222-
alert-threshold: '200%'
223-
github-token: ${{ secrets.GITHUB_TOKEN }}
224-
comment-on-alert: false
225-
fail-on-alert: false
226-
auto-push: false
180+
name: "Benchmarks"
181+
needs:
182+
- changes
183+
- style
184+
runs-on: ubuntu-latest
185+
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
186+
strategy:
187+
fail-fast: false
188+
steps:
189+
- uses: actions/checkout@v4
190+
with:
191+
fetch-depth: 0
192+
- name: Set up Python 3.10
193+
uses: mamba-org/setup-micromamba@v1
194+
with:
195+
environment-name: pytensor-test
196+
micromamba-version: "latest"
197+
init-shell: bash
198+
post-cleanup: "all"
199+
- name: Install dependencies
200+
shell: micromamba-shell {0}
201+
run: |
202+
micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service cython pytest "numba>=0.57" jax jaxlib pytest-benchmark
203+
pip install -e ./
204+
micromamba list && pip freeze
205+
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
206+
python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"'
207+
env:
208+
PYTHON_VERSION: 3.10
209+
- name: Download previous benchmark data
210+
uses: actions/cache@v4
211+
with:
212+
path: ./cache
213+
key: ${{ runner.os }}-benchmark
214+
- name: Run benchmarks
215+
shell: micromamba-shell {0}
216+
run: |
217+
export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe
218+
python -m pytest --runslow --benchmark-only --benchmark-json output.json
219+
- name: Store benchmark result
220+
uses: benchmark-action/github-action-benchmark@v1
221+
with:
222+
name: Python Benchmark with pytest-benchmark
223+
tool: "pytest"
224+
output-file-path: output.json
225+
external-data-json-path: ./cache/benchmark-data.json
226+
alert-threshold: "200%"
227+
github-token: ${{ secrets.GITHUB_TOKEN }}
228+
comment-on-alert: false
229+
fail-on-alert: false
230+
auto-push: false
227231

228232
all-checks:
229233
if: ${{ always() }}

0 commit comments

Comments
 (0)