Skip to content

Commit

Permalink
test: improve caching (#407)
Browse files Browse the repository at this point in the history
* test: improved caching

* add workflow_dispatch

* fix: tests
  • Loading branch information
lkstrp authored Nov 15, 2024
1 parent 2e445cf commit d6c21ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ on:
branches:
- master
schedule:
- cron: "0 5 * * *"
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
cache_cutouts:
description: "Cache cutouts for all Python versions"
default: "false"
required: true

# Cancel any in-progress runs when a new run is triggered
concurrency:
Expand Down Expand Up @@ -41,11 +47,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.build.outputs.python-versions) }}
os:
- ubuntu-latest
- macos-latest
- windows-latest
# Only run ubuntu/3.12 on scheduled runs to create cache
python-version: ${{ fromJSON(github.event_name == 'schedule' && '["3.12"]' || needs.build.outputs.python-versions) }}
os: ${{ fromJSON(github.event_name == 'schedule' && '["ubuntu-latest"]' || '["ubuntu-latest","macos-latest","windows-latest"]') }}
env:
MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434

Expand Down Expand Up @@ -79,12 +83,12 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Cache retrieved cutouts
if: ${{ inputs.cache_cutouts != 'false' }}
uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATH }}
key: retrieved-cutouts-${{ env.today }}
enableCrossOsArchive: true
id: cache-env

- name: Download package
uses: actions/download-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions atlite/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_windturbineconfig(
Config with details on the turbine
"""
assert isinstance(turbine, str | Path | dict)
assert isinstance(turbine, (str, Path, dict))

if add_cutout_windspeed is False:
msg = (
Expand All @@ -92,7 +92,7 @@ def get_windturbineconfig(
if isinstance(turbine, str) and turbine.startswith("oedb:"):
conf = get_oedb_windturbineconfig(turbine[len("oedb:") :])

elif isinstance(turbine, str | Path):
elif isinstance(turbine, (str, Path)):
if isinstance(turbine, str):
turbine_path = windturbines[turbine.replace(".yaml", "")]

Expand Down

0 comments on commit d6c21ba

Please sign in to comment.