diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 57fbe1f1..49aaa5c3 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -50,7 +50,7 @@ jobs: - name: download data run: | conda activate test-environment - bash scripts/download_data.sh + python download_data.py - name: generate rst run: | conda activate test-environment diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 64f3d444..9da2fa5a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -129,7 +129,7 @@ jobs: if: needs.setup.outputs.code_change == 'true' run: | conda activate test-environment - bash scripts/download_data.sh + python scripts/download_data.py - name: git describe if: needs.setup.outputs.code_change == 'true' run: | @@ -189,7 +189,7 @@ jobs: - name: download data run: | # conda activate test-environment - bash scripts/download_data.sh + python scripts/download_data.py - name: doit test_unit run: | # conda activate test-environment diff --git a/scripts/download_data.py b/scripts/download_data.py new file mode 100644 index 00000000..eed4971b --- /dev/null +++ b/scripts/download_data.py @@ -0,0 +1,33 @@ +from contextlib import suppress +from pathlib import Path + +import bokeh.sampledata + +BASE_PATH = Path(__file__).resolve().parents[1] + +bokeh.sampledata.download() + +with suppress(ImportError): + import pyct.cmd + + pyct.cmd.fetch_data( + name="data", + path=str(BASE_PATH / "examples"), + datasets="datasets.yml", + ) + + +with suppress(ImportError): + import geodatasets as gds + + gds.get_path("geoda airbnb") + gds.get_path("nybb") + + +with suppress(ImportError): + import pooch # noqa: F401 + import scipy # noqa: F401 + import xarray as xr + + xr.tutorial.open_dataset("air_temperature") + xr.tutorial.open_dataset("rasm") diff --git a/scripts/download_data.sh b/scripts/download_data.sh deleted file mode 100755 index 8baf78b4..00000000 --- a/scripts/download_data.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -set -euxo pipefail - -python -m bokeh sampledata - -HERE=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -python -m geoviews fetch-data --path="$HERE/../examples" || echo "geoviews fetch-data failed" - -python -c " -try: - import geodatasets as gds -except ImportError: - pass -else: - gds.get_path('geoda airbnb') - gds.get_path('nybb') -" - -python -c " -try: - import pooch - import scipy - import xarray as xr -except ImportError: - pass -else: - xr.tutorial.open_dataset('air_temperature') - xr.tutorial.open_dataset('rasm') -"