Skip to content

Commit

Permalink
Merge pull request #7 from jsta/ci
Browse files Browse the repository at this point in the history
Add ghactions ci validation
  • Loading branch information
jsta authored May 22, 2024
2 parents 41d3435 + 6945b8c commit fb385e8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 11 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: validate
on:
push:
branches:
- master
paths:
- '**.ipynb'
pull_request:
branches:
- master
paths:
- '**.ipynb'

jobs:
build:
name: validate notebooks
runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- name: setup env
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: cmip6env
channels: conda-forge
mamba-version: "*"
channel-priority: strict
auto-update-conda: false
environment-file: environment.yml
auto-activate-base: false

- name: verify env
run: |
conda info
conda list
python -m ipykernel install --user --name cmip6env
- name: get changed ipynb files
id: changed-ipynb-files
uses: tj-actions/changed-files@v44
with:
files: |
**.ipynb
- name: validate all changed ipynb files
if: steps.changed-ipynb-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-ipynb-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
papermill -k cmip6env $file -
done
15 changes: 4 additions & 11 deletions basic_search_and_load.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import xarray as xr\n",
"import zarr\n",
"import fsspec\n",
"import gcsfs\n",
"\n",
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'retina' \n",
Expand Down Expand Up @@ -102,7 +101,8 @@
"print(zstore)\n",
"\n",
"# create a mutable-mapping-style interface to the store\n",
"mapper = fsspec.get_mapper(zstore)\n",
"fs = gcsfs.GCSFileSystem(token='anon', session_kwargs={'trust_env': True})\n",
"mapper = fs.get_mapper(zstore)\n",
"\n",
"# open it using xarray and zarr\n",
"ds = xr.open_zarr(mapper, consolidated=True)\n",
Expand Down Expand Up @@ -139,7 +139,7 @@
"outputs": [],
"source": [
"df_area = df.query(\"variable_id == 'areacella' & source_id == 'CESM2'\")\n",
"ds_area = xr.open_zarr(fsspec.get_mapper(df_area.zstore.values[0]), consolidated=True)\n",
"ds_area = xr.open_zarr(fs.get_mapper(df_area.zstore.values[0]), consolidated=True)\n",
"ds_area"
]
},
Expand Down Expand Up @@ -181,13 +181,6 @@
"plt.legend()\n",
"plt.title('Global Mean Surface Air Temperature')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
13 changes: 13 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: cmip6env
channels:
- conda-forge
dependencies:
- zarr
- xarray
- s3fs
- gcsfs
- cftime
- nc-time-axis
- papermill
- notebook
- matplotlib

0 comments on commit fb385e8

Please sign in to comment.