Skip to content

Caching in pytest #242

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
47 changes: 26 additions & 21 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@ on:

jobs:
call-run-python-tests-unit:
uses: openclimatefix/.github/.github/workflows/python-test.yml@issue/pip-all
with:
# pytest-cov looks at this folder
pytest_cov_dir: "quartz_solar_forecast"
os_list: '["ubuntu-latest"]'
python-version: "['3.11']"
extra_commands: echo "HF_TOKEN=${{ vars.HF_TOKEN }}" > .env
pytest_numcpus: '1'
test_dir: tests/unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

call-run-python-tests-all:
# only run on push, not external PR
uses: openclimatefix/.github/.github/workflows/python-test.yml@issue/pip-all
if: github.event_name == 'push'
with:
# pytest-cov looks at this folder
pytest_cov_dir: "quartz_solar_forecast"
os_list: '["ubuntu-latest"]'
python-version: "['3.11']"
extra_commands: echo "HF_TOKEN=${{ vars.HF_TOKEN }}" > .env
pytest_numcpus: '1'
test_dir: tests
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the slow down is largely due to needed to download a model rather than pip caching.

Pip caching is currently included in workflow: https://github.com/openclimatefix/.github/blob/095e2489f12ba5269e4a6382b3db09d79c236ab6/.github/workflows/python-test.yml#L65

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install dependencies
run: pip install --upgrade pip && pip install -r requirements.txt

- name: Run tests
run: |
pytest \
--maxfail=1 \
--disable-warnings \
--cov=quartz_solar_forecast \
--cov-report=xml \
tests/unit
Loading