Skip to content

[Github Actions] Cache builds of cmdstan in the CI #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ on:
- '**'
pull_request:
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: |
echo "::set-output name=version::$(python -c 'import requests;print(requests.get("https://api.github.com/repos/stan-dev/cmdstan/releases/latest").json()["tag_name"][1:])')"
outputs:
version: ${{ steps.check-cmdstan.outputs.version }}

cmdstanpy:
needs: get-cmdstan-version
name: tests
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -52,22 +65,26 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
$whl = Get-ChildItem -Path dist -Filter *.whl | Select-Object -First 1
pip install "$whl"
pip install "$whl"

- name: Show libraries
run: python -m pip freeze

- name: CmdStan installation cacheing
uses: actions/cache@v2
with:
path: ~/.cmdstan
key: ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }}

- name: Install CmdStan (Linux, macOS)
if: matrix.os != 'windows-latest'
run: |
python -m cmdstanpy.install_cmdstan
python scripts/clean_examples.py

- name: Install CmdStan (Windows)
if: matrix.os == 'windows-latest'
run: |
python -m cmdstanpy.install_cmdstan --compiler
python scripts/clean_examples.py

- name: Run tests
run: |
Expand All @@ -80,7 +97,6 @@ jobs:
cd run_tests
python -m pip install -r ../requirements-optional.txt
python ../test/example_script.py
python ../scripts/clean_examples.py

- name: Submit codecov
run: |
Expand Down
21 changes: 0 additions & 21 deletions scripts/clean_examples.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/example_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def run_bernoulli_fit():
cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan'
)
bernoulli_model = CmdStanModel(stan_file=bernoulli_path)
bernoulli_model.compile()
bernoulli_model.compile(force=True)

# specify data, fit the model
bernoulli_data = {'N': 10, 'y': [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
Expand Down