Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Aug 27, 2024
1 parent 28eac64 commit 6f607e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ jobs:

- name: apt install
run: |
sudo apt-get install -y pkg-config petsc netcdf-fortran
sudo apt-get install -y pkg-config petsc-dev libnetcdf-dev
- name: list installed packages
run: |
pkg-config --list-all | grep petsc
pkg-config --list-all | grep netcdf
pkg-config --list-all | grep hdf
- name: Install miniconda
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down Expand Up @@ -103,7 +109,7 @@ jobs:
- name: Test notebooks
working-directory: .scripts
run: |
python test_notebooks.py
python test_notebooks.py --script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
22 changes: 21 additions & 1 deletion .scripts/test_notebooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import os
import pathlib as pl
import subprocess
Expand Down Expand Up @@ -38,6 +39,11 @@ def run_cmd(cmd):


def run_notebook(nb_name):
cmd = ("jupytext", "--execute", f"{nb_name}")
run_cmd(cmd)


def run_script(nb_name):
py_script = "test.py"
cmd = ("jupytext", "--output", f"{py_script}", f"{nb_name}")
run_cmd(cmd)
Expand All @@ -49,9 +55,23 @@ def run_notebook(nb_name):


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Test gw3099 completed notebooks."
)
parser.add_argument(
"-s",
"--script",
action="store_false",
help="Convert notebooks to scripts",
)
args = parser.parse_args()

for idx, dir_path in enumerate(DIRS):
nb_paths = get_notebook_paths(dir_path)
os.chdir(dir_path)
for p in nb_paths:
success = run_notebook(p)
if args.script:
run_script(p)
else:
run_notebook(p)
os.chdir(ROOT_DIR)

0 comments on commit 6f607e4

Please sign in to comment.