diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 17da7d6..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2.1 - -orbs: - python: circleci/python@0.2.1 - -jobs: - build_docs: - executor: python/default - steps: - - checkout - - run: - name: Install Python dependencies - command: | - python -m pip install --user \ - -r docs-requirements.txt - - run: - name: install module - command: python -m pip install --user -ve . - - run: - name: Build docs - command: cd docs/ && make html - - persist_to_workspace: - root: docs/_build/html - paths: . - - store_artifacts: - path: docs/_build/html/ - -workflows: - main: - jobs: - - build_docs diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..05822e6 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1 @@ +Follow the instructions in our [contributing page](./contributing.md). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8ac6b8c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f9641ed..746c34d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,10 @@ name: Test pyglider on: [push, pull_request] + +defaults: + run: + shell: bash -el {0} + jobs: test-gliders: name: pyglider (${{ matrix.python-version }}, ${{ matrix.os }}) @@ -7,33 +12,35 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: mamba setup enviroment uses: mamba-org/setup-micromamba@v1.9.0 with: environment-name: test-env - environment-file: tests/environment.yml + environment-file: environment.yml create-args: >- python=${{ matrix.python-version }} - - name: Conda info - shell: micromamba-shell {0} - run: conda info; conda list - name: install pyglider source - shell: micromamba-shell {0} - run: which pip; pip install -e . + run: | + pip install -e . - name: Process seaexplorer - shell: micromamba-shell {0} - run: which python; cd tests/example-data/example-seaexplorer; make clean-all; python process_deploymentRealTime.py + run: | + cd tests/example-data/example-seaexplorer + make clean-all + python process_deploymentRealTime.py - name: Process slocum - shell: micromamba-shell {0} - run: which python; cd tests/example-data/example-slocum; make clean-all; python process_deploymentRealTime.py + run: | + cd tests/example-data/example-slocum + make clean-all + python process_deploymentRealTime.py - name: Process seaexplorer-legato-flntu-arod-ad2cp - shell: micromamba-shell {0} - run: which python; cd tests/example-data/example-seaexplorer-legato-flntu-arod-ad2cp; make clean-all; python process_deploymentRealTime.py + run: | + cd tests/example-data/example-seaexplorer-legato-flntu-arod-ad2cp + make clean-all + python process_deploymentRealTime.py - name: Run tests - shell: micromamba-shell {0} - run: which python; pytest --cov --cov-report xml + run: pytest --cov --cov-report xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e55e259..13922d8 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,41 +1,11 @@ -# Read the Docs configuration file for Sphinx projects -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required version: 2 - -# Set the OS, Python version and other tools you might need build: os: ubuntu-22.04 tools: - python: "3.12" - # You can also specify other tool versions: - # nodejs: "20" - # rust: "1.70" - # golang: "1.20" + python: mambaforge-22.9 -# Build documentation in the "docs/" directory with Sphinx sphinx: configuration: docs/conf.py - # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs - # builder: "dirhtml" - # Fail on all warnings to avoid broken references - # fail_on_warning: true - -python: - install: - - requirements: docs-requirements.txt - # Install our python package before building the docs - - method: pip - path: . -# Optionally build your docs in additional formats such as PDF and ePub -# formats: -# - pdf -# - epub -# Optional but recommended, declare the Python requirements required -# to build your documentation -# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html -# python: -# install: -# - requirements: docs/requirements.txt +conda: + environment: environment.yml diff --git a/docs-requirements.txt b/docs-requirements.txt deleted file mode 100644 index 862da0e..0000000 --- a/docs-requirements.txt +++ /dev/null @@ -1,16 +0,0 @@ -numpy -xarray -dask -netcdf4 -gsw -scipy -pooch -bitstring -pydata-sphinx-theme -sphinx -pytest -autoapi -numpydoc -myst-parser -dbdreader -polars>=0.16 diff --git a/docs/Install.md b/docs/Install.md index b669500..d4ac905 100644 --- a/docs/Install.md +++ b/docs/Install.md @@ -14,14 +14,4 @@ conda install -c conda-forge pyglider ## Editable installation -If you want to be able to edit the files in `pyglider/pyglider` then install -the dependencies as above. Fork of PyGlider on github, and then clone it locally: - -``` -git clone https://github.com/yourname/pyglider.git -``` - -Navigate to the new `pyglider` directory and then do `pip install -e .`. -That will re-install pyglider with links to the local directory, so you -can edit the library files. If you do so, consider making a pull-request -with your changes! +Follow the instructions in our [contributing page](./contributing.md). diff --git a/docs/conf.py b/docs/conf.py index 80cac14..11dbcaa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,8 @@ # The full version, including alpha/beta/rc tags release = __version__ - +master_doc = 'index' +source_suffix = ['.rst', '.md'] # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be @@ -36,7 +37,7 @@ 'myst_parser', 'sphinx.ext.autodoc', 'sphinx.ext.inheritance_diagram', - 'autoapi.sphinx', + 'autoapi.extension', ] extensions.append('sphinx.ext.intersphinx') @@ -46,7 +47,7 @@ 'python': ('https://docs.python.org/3/', None), } -autoapi_modules = {'pyglider': None} +autoapi_dirs = ['../pyglider'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..d3b0e84 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,57 @@ +# Contributing + +## Create a fork + +```{note} +TODO: Create contributing page noting: +- the forking process (trimmed down) +``` + +## Development environment + +Assuming that you have Anaconda/Miniconda installed, you can create a new environment for development: + +```bash +conda create -n pyglider-dev python=3.9 +conda activate pyglider-dev +``` + +Then install the dependencies: + +```bash +conda env update -f environment.yml -n pyglider-dev +``` + +And install the package in editable mode: + +```bash +pip install -e . --no-build-isolation --no-deps +``` + +Done! + +--- + +From here, you can make the changes you want, and add tests. When you are ready, you can create a pull request into the codebase. + +## Running tests + +Once the development environment is set up, you can run the tests with: + +```bash +pytest +``` + +## Building documentation + +```{note} +TODO +``` + +## [Optional] Running pre-commit + +We use pre-commit [TODO link] to run tooling on the code to make sure that it adheres to standards that we have adopted in the codebase. This is done automatically in the cloud on all pull requests, however this can also be done locally. + +Pre-commit is already a dependency in the `environment.yml` file, so you only have to do `pre-commit install` in the repository (this will install the hooks in the repository so that they run when you commit changes). + +That's it! If you want to, you can manually run the hooks by doing `pre-commit run --all-files` (or `pre-commit run` if you only want to run on staged files). diff --git a/docs/index.md b/docs/index.md index 3b4fcaa..e28f83b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,6 +29,7 @@ Install getting-started-seaexplorer getting-started-slocum pyglider/pyglider +contributing ``` diff --git a/environment.yml b/environment.yml index 342ac48..0ffe2a2 100644 --- a/environment.yml +++ b/environment.yml @@ -1,8 +1,9 @@ -name: pyglider +name: pyglider-dev channels: - conda-forge dependencies: - - python>=3.10 + # Core + - python>=3.9 - numpy - pip - xarray @@ -13,5 +14,24 @@ dependencies: - scipy - bitstring - pooch + + # Testing + - pytest + - pytest-cov + - matplotlib + - compliance-checker + - cc-plugin-glider + + # Docs + - pydata-sphinx-theme + - sphinx + - sphinx-autoapi + - numpydoc + - myst-parser + + # QAQC + - pre_commit + - pip: + # Core - dbdreader diff --git a/pyproject.toml b/pyproject.toml index 774c93b..a820d9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,49 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "pyglider" +dynamic = ["version"] +description = "Glider data to netCDF translation in python" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.9" +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering", + "Intended Audience :: Science/Research", +] +authors = [ + { name = "Jody Klymak", email = "jklymak@gmail.com" }, +] +dependencies = [ + "bitstring", + "dask", + "gsw", + "netcdf4", + "polars", + "pooch", + "scipy", + "xarray", +] + +[project.urls] +Homepage = "https://pyglider.readthedocs.io" + +[tool.hatch.version] +path = "pyglider/_version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/pyglider", +] [tool.pytest.ini_options] addopts = ["--strict-config", "--strict-markers"] testpaths = ["tests"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 32ea70f..0000000 --- a/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -from setuptools import find_packages, setup - -from pyglider._version import __version__ - -setup( - name='pyglider', - version=__version__, - description='Glider data to netCDF translation in python', - author='Jody Klymak', - author_email='jklymak@gmail.com', - url='https://pyglider.readthedocs.io', - packages=find_packages(exclude=['tests']), - python_requires='>=3.6', - install_requires=[ - 'xarray', - 'dask', - 'netcdf4', - 'gsw', - 'scipy', - 'bitstring', - 'pooch', - 'polars', - ], - license='Apache', - extras_require={ - 'code_style': ['flake8<3.8.0,>=3.7.0', 'black', 'pre-commit==1.17.0'], - 'testing': ['pytest', 'pytest-cov'], - 'docs': ['pydata-sphinx-theme', 'numpydoc', 'autoapi', 'myst-parser', 'sphinx'], - }, - zip_safe=True, - long_description=open('README.md').read(), - long_description_content_type='text/markdown', -) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/environment.yml b/tests/environment.yml deleted file mode 100644 index cde877e..0000000 --- a/tests/environment.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: pyglider-test -channels: - - conda-forge -dependencies: - - python>=3.9 - - numpy - - pip - - xarray - - dask - - netcdf4 - - gsw - - scipy - - bitstring - - polars>=1.1 - - pytest - - pytest-cov - - pooch - - matplotlib - - compliance-checker - - cc-plugin-glider - - pip: - - dbdreader diff --git a/tests/test_pyglider.py b/tests/test_pyglider.py index f552d12..c072ca2 100644 --- a/tests/test_pyglider.py +++ b/tests/test_pyglider.py @@ -1,28 +1,24 @@ -from pathlib import Path - import numpy as np import pytest import xarray as xr import yaml import pyglider.seaexplorer as seaexplorer - -library_dir = Path(__file__).parent.parent.absolute() -example_dir = library_dir / 'tests/example-data/' +from tests.utils import EXAMPLE_DIR, LIBRARY_DIR # Create an L0 timeseries from seaexplorer data and test that the resulting netcdf # is identical to the test data -rawdir = str(example_dir / 'example-seaexplorer/realtime_raw/') + '/' -rawncdir = str(example_dir / 'example-seaexplorer/realtime_rawnc/') + '/' -deploymentyaml = str(example_dir / 'example-seaexplorer/deploymentRealtime.yml') -l0tsdir = str(example_dir / 'example-seaexplorer/L0-timeseries-test/') + '/' +rawdir = str(EXAMPLE_DIR / 'example-seaexplorer/realtime_raw/') + '/' +rawncdir = str(EXAMPLE_DIR / 'example-seaexplorer/realtime_rawnc/') + '/' +deploymentyaml = str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml') +l0tsdir = str(EXAMPLE_DIR / 'example-seaexplorer/L0-timeseries-test/') + '/' seaexplorer.raw_to_rawnc(rawdir, rawncdir, deploymentyaml) seaexplorer.merge_parquet(rawncdir, rawncdir, deploymentyaml, kind='sub') outname = seaexplorer.raw_to_L0timeseries(rawncdir, l0tsdir, deploymentyaml, kind='sub') output = xr.open_dataset(outname) # Open test data file test_data = xr.open_dataset( - library_dir + LIBRARY_DIR / 'tests/expected/example-seaexplorer/L0-timeseries/dfo-eva035-20190718.nc' ) variables = list(output.variables) @@ -61,12 +57,12 @@ def test_example_seaexplorer_metadata(): # Test that interpolation over nans does not change the output with nrt data with open(deploymentyaml) as fin: deployment = yaml.safe_load(fin) -interp_yaml = str(example_dir / 'example-seaexplorer/deploymentRealtimeInterp.yml') +interp_yaml = str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtimeInterp.yml') deployment['netcdf_variables']['interpolate'] = True with open(interp_yaml, 'w') as fout: yaml.dump(deployment, fout) l0tsdir_interp = ( - str(example_dir / 'example-seaexplorer/L0-timeseries-test-interp/') + '/' + str(EXAMPLE_DIR / 'example-seaexplorer/L0-timeseries-test-interp/') + '/' ) outname_interp = seaexplorer.raw_to_L0timeseries( @@ -91,10 +87,10 @@ def test_example_seaexplorer_interp_nrt(var): # Test raw (full resolution) seaexplorer data. -rawdir = str(example_dir / 'example-seaexplorer-raw/delayed_raw/') + '/' -rawncdir = str(example_dir / 'example-seaexplorer-raw/delayed_rawnc/') + '/' -deploymentyaml_raw = str(example_dir / 'example-seaexplorer-raw/deployment.yml') -l0tsdir = str(example_dir / 'example-seaexplorer-raw/L0-timeseries-test/') + '/' +rawdir = str(EXAMPLE_DIR / 'example-seaexplorer-raw/delayed_raw/') + '/' +rawncdir = str(EXAMPLE_DIR / 'example-seaexplorer-raw/delayed_rawnc/') + '/' +deploymentyaml_raw = str(EXAMPLE_DIR / 'example-seaexplorer-raw/deployment.yml') +l0tsdir = str(EXAMPLE_DIR / 'example-seaexplorer-raw/L0-timeseries-test/') + '/' seaexplorer.raw_to_rawnc(rawdir, rawncdir, deploymentyaml_raw) seaexplorer.merge_parquet(rawncdir, rawncdir, deploymentyaml_raw, kind='raw') outname_raw = seaexplorer.raw_to_L0timeseries( @@ -103,7 +99,7 @@ def test_example_seaexplorer_interp_nrt(var): output_raw = xr.open_dataset(outname_raw) # Open test data file test_data_raw = xr.open_dataset( - library_dir + LIBRARY_DIR / 'tests/expected/example-seaexplorer-raw/L0-timeseries/dfo-bb046-20200908.nc' ) @@ -138,12 +134,12 @@ def test_example_seaexplorer_metadata_raw(): # Test that interpolation over nans in raw data results in a greater or equal number of non-nan values with open(deploymentyaml_raw) as fin: deployment_raw = yaml.safe_load(fin) -interp_yaml = str(example_dir / 'example-seaexplorer-raw/deploymentDelayedInterp.yml') +interp_yaml = str(EXAMPLE_DIR / 'example-seaexplorer-raw/deploymentDelayedInterp.yml') deployment_raw['netcdf_variables']['interpolate'] = True with open(interp_yaml, 'w') as fout: yaml.dump(deployment_raw, fout) l0tsdir_interp_raw = ( - str(example_dir / 'example-seaexplorer-raw/L0-timeseries-test-interp/') + '/' + str(EXAMPLE_DIR / 'example-seaexplorer-raw/L0-timeseries-test-interp/') + '/' ) outname_interp_raw = seaexplorer.raw_to_L0timeseries( diff --git a/tests/test_seaexplorer.py b/tests/test_seaexplorer.py index c4b09f5..64c5a5d 100644 --- a/tests/test_seaexplorer.py +++ b/tests/test_seaexplorer.py @@ -1,5 +1,4 @@ import os -from pathlib import Path import numpy as np import polars as pl @@ -7,10 +6,9 @@ import yaml os.system('rm tests/data/realtime_rawnc/*') -library_dir = Path(__file__).parent.parent.absolute() -example_dir = library_dir / 'tests/example-data/' import pyglider.seaexplorer as seaexplorer +from tests.utils import EXAMPLE_DIR def test__outputname(): @@ -67,13 +65,13 @@ def test_merge_rawnc(): result_default = seaexplorer.merge_parquet( 'tests/data/realtime_rawnc/', 'tests/data/realtime_rawnc/', - str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml'), ) result_sub = seaexplorer.merge_parquet( 'tests/data/realtime_rawnc/', 'tests/data/realtime_rawnc/', - str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml'), kind='sub', ) assert result_default is False @@ -107,12 +105,12 @@ def test_raw_to_timeseries(): result_default = seaexplorer.raw_to_timeseries( 'tests/data/realtime_rawnc/', 'tests/data/l0-profiles/', - str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml'), ) result_sub = seaexplorer.raw_to_timeseries( 'tests/data/realtime_rawnc/', 'tests/data/l0-profiles/', - str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml'), kind='sub', ) assert 'No such file or directory' in str(missing_file_exc) @@ -121,26 +119,26 @@ def test_raw_to_timeseries(): def test_missing_bad_timebase(): # Prepare yaml files with bad timebase and no timebase - with open(example_dir / 'example-seaexplorer/deploymentRealtime.yml') as fin: + with open(EXAMPLE_DIR / 'example-seaexplorer/deploymentRealtime.yml') as fin: deployment = yaml.safe_load(fin) deployment['netcdf_variables']['timebase']['source'] = 'non existing sensor' - with open(example_dir / 'example-seaexplorer/bad_timebase.yml', 'w') as fin: + with open(EXAMPLE_DIR / 'example-seaexplorer/bad_timebase.yml', 'w') as fin: yaml.dump(deployment, fin) deployment['netcdf_variables'].pop('timebase') - with open(example_dir / 'example-seaexplorer/no_timebase.yml', 'w') as fin: + with open(EXAMPLE_DIR / 'example-seaexplorer/no_timebase.yml', 'w') as fin: yaml.dump(deployment, fin) with pytest.raises(ValueError) as bad_timebase_exc: result_bad_timebase = seaexplorer.raw_to_timeseries( 'tests/data/realtime_rawnc/', 'tests/data/l0-profiles/', - str(example_dir / 'example-seaexplorer/bad_timebase.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/bad_timebase.yml'), kind='sub', ) with pytest.raises(ValueError) as no_timebase_exc: result_no_timebase = seaexplorer.raw_to_timeseries( 'tests/data/realtime_rawnc/', 'tests/data/l0-profiles/', - str(example_dir / 'example-seaexplorer/no_timebase.yml'), + str(EXAMPLE_DIR / 'example-seaexplorer/no_timebase.yml'), kind='sub', ) assert 'sensor not found in pld1 columns' in str(bad_timebase_exc) diff --git a/tests/test_slocum.py b/tests/test_slocum.py index 565667a..c07b031 100644 --- a/tests/test_slocum.py +++ b/tests/test_slocum.py @@ -1,5 +1,4 @@ import json -from pathlib import Path import numpy as np import pytest @@ -8,21 +7,19 @@ import pyglider.ncprocess as ncprocess import pyglider.slocum as slocum - -library_dir = Path(__file__).parent.parent.absolute() -example_dir = library_dir / 'tests/example-data/' +from tests.utils import EXAMPLE_DIR, LIBRARY_DIR # Create an L0 timeseries from slocum data and test that the resulting netcdf is # identical to the test data -cacdir = example_dir / 'example-slocum/cac/' -sensorlist = str(example_dir / 'example-slocum/dfo-rosie713_sensors.txt') -binarydir = str(example_dir / 'example-slocum/realtime_raw/') + '/' -rawdir_slocum = str(example_dir / 'example-slocum/realtime_rawnc/') + '/' -deploymentyaml_slocum = str(example_dir / 'example-slocum/deploymentRealtime.yml') -tsdir = str(example_dir / 'example-slocum/L0-timeseries/') + '/' +cacdir = EXAMPLE_DIR / 'example-slocum/cac/' +sensorlist = str(EXAMPLE_DIR / 'example-slocum/dfo-rosie713_sensors.txt') +binarydir = str(EXAMPLE_DIR / 'example-slocum/realtime_raw/') + '/' +rawdir_slocum = str(EXAMPLE_DIR / 'example-slocum/realtime_rawnc/') + '/' +deploymentyaml_slocum = str(EXAMPLE_DIR / 'example-slocum/deploymentRealtime.yml') +tsdir = str(EXAMPLE_DIR / 'example-slocum/L0-timeseries/') + '/' scisuffix = 'tbd' glidersuffix = 'sbd' -profiledir = str(example_dir / 'example-slocum/L0-profiles/') +profiledir = str(EXAMPLE_DIR / 'example-slocum/L0-profiles/') do_direct = True # This needs to get run every time the tests are run, so do at top level: @@ -45,7 +42,7 @@ output_slocum = xr.open_dataset(outname_slocum) # Open test data file test_data_slocum = xr.open_dataset( - library_dir / 'tests/expected/example-slocum/L0-timeseries/dfo-rosie713-20190615.nc' + LIBRARY_DIR / 'tests/expected/example-slocum/L0-timeseries/dfo-rosie713-20190615.nc' ) variables_slocum = list(output_slocum.variables) @@ -95,7 +92,7 @@ def test_profiles_compliant(): checker_names = ['gliderdac', 'cf:1.8'] verbose = 0 criteria = 'normal' - output_filename = example_dir / 'report.json' + output_filename = EXAMPLE_DIR / 'report.json' output_format = 'json' """ Inputs to ComplianceChecker.run_checker @@ -139,7 +136,7 @@ def test_timeseries_compliant(): checker_names = ['cf:1.8'] verbose = 0 criteria = 'normal' - output_filename = example_dir / 'report.json' + output_filename = EXAMPLE_DIR / 'report.json' output_format = 'json' """ Inputs to ComplianceChecker.run_checker diff --git a/tests/test_utils.py b/tests/test_utils.py index 0d3e935..ed93de4 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,21 +1,17 @@ -from pathlib import Path - import numpy as np import pytest import xarray as xr import yaml import pyglider.utils as utils - -library_dir = Path(__file__).parent.parent.absolute() -example_dir = library_dir / 'tests/example-data/' +from tests.utils import EXAMPLE_DIR, LIBRARY_DIR test_data = xr.open_dataset( - library_dir + LIBRARY_DIR / 'tests/expected/example-seaexplorer/L0-timeseries/dfo-eva035-20190718.nc' ) deploymentyaml = ( - example_dir / 'example-seaexplorer-legato-flntu-arod-ad2cp/deploymentRealtime.yml' + EXAMPLE_DIR / 'example-seaexplorer-legato-flntu-arod-ad2cp/deploymentRealtime.yml' ) with open(deploymentyaml) as fin: deployment = yaml.safe_load(fin) diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..aac3421 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,6 @@ +"""Utilities specific to the test suite.""" + +from pathlib import Path + +LIBRARY_DIR = Path(__file__).parent.parent.absolute() +EXAMPLE_DIR = LIBRARY_DIR / 'tests/example-data/'