Skip to content

Commit d6c21ba

Browse files
authored
test: improve caching (#407)
* test: improved caching * add workflow_dispatch * fix: tests
1 parent 2e445cf commit d6c21ba

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

.github/workflows/test.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ on:
1111
branches:
1212
- master
1313
schedule:
14-
- cron: "0 5 * * *"
14+
- cron: "0 1 * * *"
15+
workflow_dispatch:
16+
inputs:
17+
cache_cutouts:
18+
description: "Cache cutouts for all Python versions"
19+
default: "false"
20+
required: true
1521

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

@@ -79,12 +83,12 @@ jobs:
7983
python-version: ${{ matrix.python-version }}
8084

8185
- name: Cache retrieved cutouts
86+
if: ${{ inputs.cache_cutouts != 'false' }}
8287
uses: actions/cache@v4
8388
with:
8489
path: ${{ env.CACHE_PATH }}
8590
key: retrieved-cutouts-${{ env.today }}
8691
enableCrossOsArchive: true
87-
id: cache-env
8892

8993
- name: Download package
9094
uses: actions/download-artifact@v4

atlite/resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_windturbineconfig(
8080
Config with details on the turbine
8181
8282
"""
83-
assert isinstance(turbine, str | Path | dict)
83+
assert isinstance(turbine, (str, Path, dict))
8484

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

95-
elif isinstance(turbine, str | Path):
95+
elif isinstance(turbine, (str, Path)):
9696
if isinstance(turbine, str):
9797
turbine_path = windturbines[turbine.replace(".yaml", "")]
9898

0 commit comments

Comments
 (0)