diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 181821d6f5..7dd4347d53 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -10,35 +10,22 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} steps: - uses: actions/checkout@v4 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if environment.yml has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: ~/conda_pkgs_dir - 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 + micromamba-version: "latest" # any version from https://github.com/mamba-org/micromamba-releases environment-file: environment.yml - python-version: "3.10" - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 - - name: Install-pytensor and mypy dependencies + init-shell: bash + cache-environment: true + post-cleanup: "all" + - name: Install pytensor and mypy dependencies run: | - conda activate pytensor-test pip install -e . python --version + shell: micromamba-shell {0} - name: Run mypy run: | - conda activate pytensor-test - python ./scripts/run_mypy.py --verbose \ No newline at end of file + python ./scripts/run_mypy.py --verbose + shell: micromamba-shell {0} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18628cfda9..096b47ab72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,11 +55,11 @@ jobs: matrix: python-version: ["3.10", "3.12"] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - uses: pre-commit/action@v3.0.1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - uses: pre-commit/action@v3.0.1 test_ubuntu: name: "Test py${{ matrix.python-version }} : fast-compile ${{ matrix.fast-compile }} : float32 ${{ matrix.float32 }} : ${{ matrix.part }}" @@ -72,8 +72,8 @@ jobs: fail-fast: false matrix: python-version: ["3.10", "3.12"] - fast-compile: [0,1] - float32: [0,1] + fast-compile: [0, 1] + float32: [0, 1] install-numba: [0] install-jax: [0] part: @@ -84,7 +84,7 @@ jobs: - "tests/tensor/conv" - "tests/tensor/rewriting" - "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" exclude: - python-version: "3.10" @@ -121,11 +121,13 @@ jobs: with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: conda-incubator/setup-miniconda@v3 + uses: mamba-org/setup-micromamba@v1 with: - miniforge-variant: Mambaforge - miniforge-version: latest - python-version: ${{ matrix.python-version }} + environment-name: pytensor-test + micromamba-version: "latest" + init-shell: bash + post-cleanup: "all" + create-args: python=${{ matrix.python-version }} - name: Create matrix id id: matrix-id @@ -138,13 +140,13 @@ jobs: echo "id=$MATRIX_ID" >> $GITHUB_OUTPUT - name: Install dependencies - shell: bash -l {0} + shell: micromamba-shell {0} 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 - if [[ $INSTALL_NUMBA == "1" ]]; then mamba 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 + 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 micromamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" "numba>=0.57"; 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 ./ - mamba list && pip freeze + micromamba list && pip freeze python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))' python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"' env: @@ -153,7 +155,7 @@ jobs: INSTALL_JAX: ${{ matrix.install-jax }} - name: Run tests - shell: bash -l {0} + shell: micromamba-shell {0} run: | 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 @@ -175,55 +177,57 @@ jobs: path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml benchmarks: - name: "Benchmarks" - needs: - - changes - - style - runs-on: ubuntu-latest - if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python 3.10 - uses: conda-incubator/setup-miniconda@v3 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - - name: Install dependencies - shell: bash -l {0} - run: | - 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 - pip install -e ./ - mamba list && pip freeze - python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))' - python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"' - env: - PYTHON_VERSION: 3.10 - - name: Download previous benchmark data - uses: actions/cache@v4 - with: - path: ./cache - key: ${{ runner.os }}-benchmark - - name: Run benchmarks - shell: bash -l {0} - run: | - export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe - python -m pytest --runslow --benchmark-only --benchmark-json output.json - - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@v1 - with: - name: Python Benchmark with pytest-benchmark - tool: 'pytest' - output-file-path: output.json - external-data-json-path: ./cache/benchmark-data.json - alert-threshold: '200%' - github-token: ${{ secrets.GITHUB_TOKEN }} - comment-on-alert: false - fail-on-alert: false - auto-push: false + name: "Benchmarks" + needs: + - changes + - style + runs-on: ubuntu-latest + if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python 3.10 + uses: mamba-org/setup-micromamba@v1 + with: + environment-name: pytensor-test + micromamba-version: "latest" + init-shell: bash + post-cleanup: "all" + - name: Install dependencies + shell: micromamba-shell {0} + run: | + 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 + pip install -e ./ + micromamba list && pip freeze + python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))' + python -c 'import pytensor; assert pytensor.config.blas__ldflags != "", "Blas flags are empty"' + env: + PYTHON_VERSION: 3.10 + - name: Download previous benchmark data + uses: actions/cache@v4 + with: + path: ./cache + key: ${{ runner.os }}-benchmark + - name: Run benchmarks + shell: micromamba-shell {0} + run: | + export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe + python -m pytest --runslow --benchmark-only --benchmark-json output.json + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Python Benchmark with pytest-benchmark + tool: "pytest" + output-file-path: output.json + external-data-json-path: ./cache/benchmark-data.json + alert-threshold: "200%" + github-token: ${{ secrets.GITHUB_TOKEN }} + comment-on-alert: false + fail-on-alert: false + auto-push: false all-checks: if: ${{ always() }}