-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e9d1d2
commit 7711c82
Showing
11 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Python Package using Conda | ||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Test python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macOS-latest] | ||
python-version: [3.7] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: install mamba | ||
uses: mamba-org/provision-with-micromamba@main | ||
with: | ||
environment-file: CNN.yml | ||
environment-name: CNN | ||
- name: Install test packages | ||
shell: bash -l {0} | ||
run: | | ||
pip install pytest nbconvert nbformat | ||
- name: which python | ||
shell: bash -l {0} | ||
run: | | ||
which python | ||
- name: Test with pytest | ||
shell: bash -l {0} | ||
run: | | ||
pytest .github/workflows/test_CNN_notebooks.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Tests for checking that all Jupyter notebooks in repository execute without errors. | ||
Based on https://github.com/mcullan/jupyter-actions/blob/master/test/test_notebooks.py | ||
Leif Denby - MIT License 2021 | ||
""" | ||
import os | ||
import subprocess | ||
import pytest | ||
from pathlib import Path | ||
|
||
import nbformat | ||
from nbconvert.preprocessors import ExecutePreprocessor | ||
|
||
TEST_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
PARENT_DIR = os.path.join(TEST_DIR, "../") | ||
|
||
|
||
def _find_notebooks(): | ||
# Get all files included in the git repository | ||
git_files = ( | ||
subprocess.check_output( | ||
"git ls-tree --full-tree --name-only -r HEAD", shell=True | ||
) | ||
.decode("utf-8") | ||
.splitlines() | ||
) | ||
|
||
# Get just the notebooks from the git files | ||
notebooks_files = [Path(fn) for fn in git_files if fn.endswith("CNN_Volcanic_deformation_test.ipynb")] | ||
|
||
# remove all notebooks that haven't been checked | ||
notebooks_files = [p for p in notebooks_files if p.parent.name != "unchecked"] | ||
return [str(p) for p in notebooks_files] | ||
|
||
|
||
@pytest.mark.parametrize("notebook_filename", _find_notebooks()) | ||
def test_notebook(notebook_filename, html_directory="notebook-html"): | ||
""" | ||
Checks if an IPython notebook runs without error from start to finish. | ||
""" | ||
with open(notebook_filename) as f: | ||
nb = nbformat.read(f, as_version=4) | ||
|
||
ep = ExecutePreprocessor(timeout=600) | ||
|
||
# Check that the notebook runs | ||
ep.preprocess(nb, {"metadata": {"path": Path(notebook_filename).parent }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Python Package using Conda | ||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Test python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
python-version: [3.7] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: install mamba | ||
uses: mamba-org/provision-with-micromamba@main | ||
with: | ||
environment-file: CNN_windows.yml | ||
environment-name: CNN | ||
- name: Install test packages | ||
shell: bash -l {0} | ||
run: | | ||
pip install pytest nbconvert nbformat | ||
- name: which python | ||
shell: bash -l {0} | ||
run: | | ||
which python | ||
- name: Test with pytest | ||
shell: bash -l {0} | ||
run: | | ||
pytest .github/workflows/test_CNN_notebooks.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ConvolutionalNeuralNetworks/**/*.npz | ||
**/.ipynb_checkpoints/ | ||
**/__pycache__ | ||
ConvolutionalNeuralNetworks/data/real/ | ||
ConvolutionalNeuralNetworks/data/train_full_model/ | ||
ConvolutionalNeuralNetworks/data/train_fully_connected_model/ | ||
ConvolutionalNeuralNetworks/vgg16_2head.png |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.