Unverified 提交 75a9fd2a authored 作者: Pham Nguyen Hung's avatar Pham Nguyen Hung 提交者: GitHub

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
上级 6857517c
...@@ -10,35 +10,22 @@ jobs: ...@@ -10,35 +10,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
run: run:
shell: bash -l {0} shell: bash -leo pipefail {0}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Cache conda - uses: mamba-org/setup-micromamba@v1
uses: actions/cache@v4
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with: with:
path: ~/conda_pkgs_dir micromamba-version: "latest" # any version from https://github.com/mamba-org/micromamba-releases
key: ${{ runner.os }}-py310-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('environment.yml') }}
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
mamba-version: "*"
activate-environment: pytensor-test
channel-priority: strict
environment-file: environment.yml environment-file: environment.yml
python-version: "3.10" init-shell: bash
use-mamba: true cache-environment: true
use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 post-cleanup: "all"
- name: Install-pytensor and mypy dependencies - name: Install pytensor and mypy dependencies
run: | run: |
conda activate pytensor-test
pip install -e . pip install -e .
python --version python --version
shell: micromamba-shell {0}
- name: Run mypy - name: Run mypy
run: | run: |
conda activate pytensor-test python ./scripts/run_mypy.py --verbose
python ./scripts/run_mypy.py --verbose shell: micromamba-shell {0}
\ No newline at end of file
...@@ -55,11 +55,11 @@ jobs: ...@@ -55,11 +55,11 @@ jobs:
matrix: matrix:
python-version: ["3.10", "3.12"] python-version: ["3.10", "3.12"]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@v3.0.1
test_ubuntu: test_ubuntu:
name: "Test py${{ matrix.python-version }} : fast-compile ${{ matrix.fast-compile }} : float32 ${{ matrix.float32 }} : ${{ matrix.part }}" name: "Test py${{ matrix.python-version }} : fast-compile ${{ matrix.fast-compile }} : float32 ${{ matrix.float32 }} : ${{ matrix.part }}"
...@@ -72,8 +72,8 @@ jobs: ...@@ -72,8 +72,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: ["3.10", "3.12"] python-version: ["3.10", "3.12"]
fast-compile: [0,1] fast-compile: [0, 1]
float32: [0,1] float32: [0, 1]
install-numba: [0] install-numba: [0]
install-jax: [0] install-jax: [0]
part: part:
...@@ -84,7 +84,7 @@ jobs: ...@@ -84,7 +84,7 @@ jobs:
- "tests/tensor/conv" - "tests/tensor/conv"
- "tests/tensor/rewriting" - "tests/tensor/rewriting"
- "tests/tensor/test_math.py" - "tests/tensor/test_math.py"
- "tests/tensor/test_basic.py tests/tensor/test_inplace.py" - "tests/tensor/test_basic.py tests/tensor/test_inplace.py"
- "tests/tensor/test_blas.py tests/tensor/test_elemwise.py tests/tensor/test_math_scipy.py" - "tests/tensor/test_blas.py tests/tensor/test_elemwise.py tests/tensor/test_math_scipy.py"
exclude: exclude:
- python-version: "3.10" - python-version: "3.10"
...@@ -121,11 +121,13 @@ jobs: ...@@ -121,11 +121,13 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v3 uses: mamba-org/setup-micromamba@v1
with: with:
miniforge-variant: Mambaforge environment-name: pytensor-test
miniforge-version: latest micromamba-version: "latest"
python-version: ${{ matrix.python-version }} init-shell: bash
post-cleanup: "all"
create-args: python=${{ matrix.python-version }}
- name: Create matrix id - name: Create matrix id
id: matrix-id id: matrix-id
...@@ -138,13 +140,13 @@ jobs: ...@@ -138,13 +140,13 @@ jobs:
echo "id=$MATRIX_ID" >> $GITHUB_OUTPUT echo "id=$MATRIX_ID" >> $GITHUB_OUTPUT
- name: Install dependencies - name: Install dependencies
shell: bash -l {0} shell: micromamba-shell {0}
run: | run: |
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 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
if [[ $INSTALL_NUMBA == "1" ]]; then mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; fi if [[ $INSTALL_NUMBA == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; fi
if [[ $INSTALL_JAX == "1" ]]; then mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" jax jaxlib numpyro && pip install tensorflow-probability; fi if [[ $INSTALL_JAX == "1" ]]; then micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" jax jaxlib numpyro && pip install tensorflow-probability; fi
pip install -e ./ pip install -e ./
mamba list && pip freeze micromamba list && pip freeze
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))' python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"' python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"'
env: env:
...@@ -153,7 +155,7 @@ jobs: ...@@ -153,7 +155,7 @@ jobs:
INSTALL_JAX: ${{ matrix.install-jax }} INSTALL_JAX: ${{ matrix.install-jax }}
- name: Run tests - name: Run tests
shell: bash -l {0} shell: micromamba-shell {0}
run: | run: |
if [[ $FAST_COMPILE == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,mode=FAST_COMPILE; fi if [[ $FAST_COMPILE == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,mode=FAST_COMPILE; fi
if [[ $FLOAT32 == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,floatX=float32; fi if [[ $FLOAT32 == "1" ]]; then export PYTENSOR_FLAGS=$PYTENSOR_FLAGS,floatX=float32; fi
...@@ -175,55 +177,57 @@ jobs: ...@@ -175,55 +177,57 @@ jobs:
path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml
benchmarks: benchmarks:
name: "Benchmarks" name: "Benchmarks"
needs: needs:
- changes - changes
- style - style
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
strategy: strategy:
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Python 3.10 - name: Set up Python 3.10
uses: conda-incubator/setup-miniconda@v3 uses: mamba-org/setup-micromamba@v1
with: with:
miniforge-variant: Mambaforge environment-name: pytensor-test
miniforge-version: latest micromamba-version: "latest"
- name: Install dependencies init-shell: bash
shell: bash -l {0} post-cleanup: "all"
run: | - name: Install dependencies
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 shell: micromamba-shell {0}
pip install -e ./ run: |
mamba list && pip freeze 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
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))' pip install -e ./
python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"' micromamba list && pip freeze
env: python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
PYTHON_VERSION: 3.10 python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"'
- name: Download previous benchmark data env:
uses: actions/cache@v4 PYTHON_VERSION: 3.10
with: - name: Download previous benchmark data
path: ./cache uses: actions/cache@v4
key: ${{ runner.os }}-benchmark with:
- name: Run benchmarks path: ./cache
shell: bash -l {0} key: ${{ runner.os }}-benchmark
run: | - name: Run benchmarks
export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe shell: micromamba-shell {0}
python -m pytest --runslow --benchmark-only --benchmark-json output.json run: |
- name: Store benchmark result export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe
uses: benchmark-action/github-action-benchmark@v1 python -m pytest --runslow --benchmark-only --benchmark-json output.json
with: - name: Store benchmark result
name: Python Benchmark with pytest-benchmark uses: benchmark-action/github-action-benchmark@v1
tool: 'pytest' with:
output-file-path: output.json name: Python Benchmark with pytest-benchmark
external-data-json-path: ./cache/benchmark-data.json tool: "pytest"
alert-threshold: '200%' output-file-path: output.json
github-token: ${{ secrets.GITHUB_TOKEN }} external-data-json-path: ./cache/benchmark-data.json
comment-on-alert: false alert-threshold: "200%"
fail-on-alert: false github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false comment-on-alert: false
fail-on-alert: false
auto-push: false
all-checks: all-checks:
if: ${{ always() }} if: ${{ always() }}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论