Enable save_metric=1 and sources MCMC metric info from new JSON file
#1236
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CmdStanPy | |
| on: | |
| push: | |
| branches: | |
| - 'develop' | |
| - 'master' | |
| tags: | |
| - '**' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| cmdstan-version: | |
| description: 'Version to test' | |
| required: false | |
| default: '' | |
| # only run one copy per PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| get-cmdstan-version: | |
| # get the latest cmdstan version to use as part of the cache key | |
| name: grab version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get CmdStan version | |
| id: check-cmdstan | |
| run: | | |
| if [[ "${{ github.event.inputs.cmdstan-version }}" != "" ]]; then | |
| echo "version=${{ github.event.inputs.cmdstan-version }}" >> $GITHUB_OUTPUT | |
| else | |
| python -c 'import requests;print("version="+requests.get("https://api.github.com/repos/stan-dev/cmdstan/releases/latest").json()["tag_name"][1:])' >> $GITHUB_OUTPUT | |
| fi | |
| outputs: | |
| version: ${{ steps.check-cmdstan.outputs.version }} | |
| cmdstanpy: | |
| needs: get-cmdstan-version | |
| name: tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Check out github | |
| uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: python -m pip install --upgrade pip wheel build | |
| - name: Build package | |
| run: | | |
| python -m build | |
| python -m pip install .[test] | |
| - name: Show libraries | |
| run: python -m pip freeze | |
| - name: Run flake8, pylint, mypy | |
| if: matrix.python-version == '3.14' | |
| run: | | |
| flake8 cmdstanpy test | |
| pylint -v cmdstanpy test | |
| mypy cmdstanpy test | |
| - name: CmdStan installation cacheing | |
| id: cache-cmdstan | |
| if: ${{ !startswith(needs.get-cmdstan-version.outputs.version, 'git:') }} | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cmdstan | |
| key: ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }} | |
| - name: Delete precompiled header (MacOS) | |
| if: matrix.os == 'macos-latest' && steps.cache-cmdstan.outputs.cache-hit == 'true' | |
| run: rm -rf ~/.cmdstan/cmdstan-${{ needs.get-cmdstan-version.outputs.version }}/stan/src/stan/model/*.hpp.gch | |
| - name: Install CmdStan (Linux, macOS) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| install_cmdstan -h | |
| install_cxx_toolchain -h | |
| python -c "import cmdstanpy; cmdstanpy.install_cmdstan(version='${{ needs.get-cmdstan-version.outputs.version }}', cores=4)" | |
| - name: Install CmdStan (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| install_cmdstan -h | |
| install_cxx_toolchain -h | |
| python -m cmdstanpy.install_cmdstan --version ${{ needs.get-cmdstan-version.outputs.version }} --cores 4 | |
| - name: Run tests | |
| run: | | |
| mkdir run_tests | |
| cd run_tests | |
| pytest -v ../test --cov=../cmdstanpy | |
| - name: Submit codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| directory: ./run_tests |