From cb8341790442b0d6b0099075665fe96a2a33b956 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 15 Aug 2023 15:22:39 -0700 Subject: [PATCH] Testing updates (#133) update the environment file, break up testing --- .github/workflows/tests.yml | 28 ++++++++++++++----------- environment.yml | 42 +++++++++++++------------------------ setup.sh | 2 +- tests/test_dcip.py | 28 +++++++++++++++++++++++++ tests/test_em.py | 28 +++++++++++++++++++++++++ tests/test_gpr.py | 28 +++++++++++++++++++++++++ tests/test_mag.py | 28 +++++++++++++++++++++++++ tests/test_notebooks.py | 28 ------------------------- tests/test_seismic.py | 28 +++++++++++++++++++++++++ 9 files changed, 171 insertions(+), 69 deletions(-) create mode 100644 tests/test_dcip.py create mode 100644 tests/test_em.py create mode 100644 tests/test_gpr.py create mode 100644 tests/test_mag.py delete mode 100644 tests/test_notebooks.py create mode 100644 tests/test_seismic.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6a92b7f..2a6e30e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,29 +11,33 @@ jobs: setup-build: name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} strategy: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: [3.8] + python-version: ["3.10"] + test_file: ["tests/test_dcip.py", "tests/test_em.py", "tests/test_gpr.py", "tests/test_mag.py", "tests/test_seismic.py"] steps: - uses: actions/checkout@v2 - name: Setup Conda - uses: s-weigand/setup-conda@v1 + uses: conda-incubator/setup-miniconda@v2 with: - update-conda: true - conda-channels: conda-forge + auto-update-conda: true + activate-environment: geosci-labs + channels: conda-forge + environment-file: environment.yml python-version: ${{ matrix.python-version }} - - name: Install Env - shell: bash run: | - python --version - conda env create -f environment-dev.yml - + conda info + conda config --show + conda install -y pytest + pip install testipynb + conda list - name: Run Tests - shell: bash run: | - source activate geosci-labs - pytest . + pytest -v ${{ matrix.test_file }} diff --git a/environment.yml b/environment.yml index 62b5bd7..defdfc6 100644 --- a/environment.yml +++ b/environment.yml @@ -1,37 +1,23 @@ -name: e350 +name: geosci-labs channels: - conda-forge dependencies: - - mamba - - notebook - - jupyterhub - - jupyterlab - - bokeh - - conda-lock - - ghp-import - - git - - jupytext - - jupyter-resource-usage - - matplotlib=3.4.3 - - numpy=1.21 - - nbgitpuller - - pandas - - pip - - pillow - - python=3.9 + - cvxopt + - deepdish - discretize - - empymod - - ipykernel - - ipywidgets=7.7.1 - - mkl - - nb_conda_kernels + - empymod=2.0.0 + - ipywidgets>=0.6.0 + - jupyter + - matplotlib<3.5 + - mkl>=2021.3.0 + - numpy + - Pillow + - pip - pymatsolver - - qtconsole - - qtpy + - python=3.10 + - requests - scipy - - scikit-learn - - discretize=0.8.0 - - SimPEG=0.17.0 + - SimPEG - pip: - git+https://github.com/geoscixyz/geosci-labs diff --git a/setup.sh b/setup.sh index a4231cb..a6948b2 100644 --- a/setup.sh +++ b/setup.sh @@ -9,7 +9,7 @@ mamba env create -f environment.yml --prefix ./envs # activate enviornment mamba activate ./envs -python -m ipykernel install --user --name=e350 +python -m ipykernel install --user --name=geosci # success echo "Success!" diff --git a/tests/test_dcip.py b/tests/test_dcip.py new file mode 100644 index 0000000..b415613 --- /dev/null +++ b/tests/test_dcip.py @@ -0,0 +1,28 @@ +import unittest +import os +import testipynb + +TESTDIR = os.path.abspath(__file__) + +NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) +Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +TestsDC = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsEM = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsGPR = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsMag = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsSeis = Test.get_tests() + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_em.py b/tests/test_em.py new file mode 100644 index 0000000..61050c3 --- /dev/null +++ b/tests/test_em.py @@ -0,0 +1,28 @@ +import unittest +import os +import testipynb + +TESTDIR = os.path.abspath(__file__) + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsDC = Test.get_tests() + +NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) +Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +TestsEM = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsGPR = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsMag = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsSeis = Test.get_tests() + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_gpr.py b/tests/test_gpr.py new file mode 100644 index 0000000..b77dbb4 --- /dev/null +++ b/tests/test_gpr.py @@ -0,0 +1,28 @@ +import unittest +import os +import testipynb + +TESTDIR = os.path.abspath(__file__) + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsDC = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsEM = Test.get_tests() + +NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) +Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +TestsGPR = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsMag = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsSeis = Test.get_tests() + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_mag.py b/tests/test_mag.py new file mode 100644 index 0000000..ed734c5 --- /dev/null +++ b/tests/test_mag.py @@ -0,0 +1,28 @@ +import unittest +import os +import testipynb + +TESTDIR = os.path.abspath(__file__) + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsDC = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsEM = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsGPR = Test.get_tests() + +NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) +Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +TestsMag = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsSeis = Test.get_tests() + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py deleted file mode 100644 index 529a375..0000000 --- a/tests/test_notebooks.py +++ /dev/null @@ -1,28 +0,0 @@ -import unittest -import os -import testipynb - -TESTDIR = os.path.abspath(__file__) - -NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) -Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) -TestsDC = Test.get_tests() - -NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) -Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) -TestsEM = Test.get_tests() - -NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) -Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) -TestsGPR = Test.get_tests() - -NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) -Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) -TestsMag = Test.get_tests() - -NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) -Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) -TestsSeis = Test.get_tests() - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_seismic.py b/tests/test_seismic.py new file mode 100644 index 0000000..ee61540 --- /dev/null +++ b/tests/test_seismic.py @@ -0,0 +1,28 @@ +import unittest +import os +import testipynb + +TESTDIR = os.path.abspath(__file__) + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "dcip"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsDC = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "em"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsEM = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "gpr"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsGPR = Test.get_tests() + +# NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "mag"]) +# Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +# TestsMag = Test.get_tests() + +NBDIR = os.path.sep.join(TESTDIR.split(os.path.sep)[:-2] + ["notebooks", "seismic"]) +Test = testipynb.TestNotebooks(directory=NBDIR, timeout=2100) +TestsSeis = Test.get_tests() + +if __name__ == "__main__": + unittest.main()