diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ee347903..e22cbb33 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9] + python-version: ["3.11"] # Keep this version at the highest supported Python version name: Documentation tests steps: @@ -26,8 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r test_requirements.txt - pip install -r requirements.txt + pip install .[doc] - name: Set up pysat run: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca28a09b..002f64c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,16 +50,11 @@ jobs: if: ${{ matrix.test_config == 'NEP29'}} run: | pip install numpy==${{ matrix.numpy_ver }} - pip install --upgrade-strategy only-if-needed -r requirements.txt - pip install --upgrade-strategy only-if-needed -r test_requirements.txt - pip install . + pip install --upgrade-strategy only-if-needed .[test] - name: Install standard dependencies if: ${{ matrix.test_config == 'latest'}} - run: | - pip install -r test_requirements.txt - pip install -r requirements.txt - pip install . + run: pip install .[test] - name: Set up pysat run: | @@ -72,18 +67,23 @@ jobs: - name: Evaluate complexity run: flake8 . --count --exit-zero --max-complexity=10 --statistics - - name: Install Operational dependencies success - if: ${{ matrix.test_config == 'Ops'}} - run: | - pip install pysatNASA==0.0.5 - which python - python --version - python -c "import pysatNASA; print(pysatNASA.__version__)" - - name: Run unit and integration tests run: pytest --cov=pysatModels/ - name: Publish results to coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: coveralls --rcfile=setup.cfg --service=github + COVERALLS_PARALLEL: true + run: coveralls --rcfile=pyproject.toml --service=github + + finish: + name: Finish Coverage Analysis + needs: build + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install --upgrade coveralls + coveralls --service=github --finish diff --git a/.github/workflows/pysat_rc.yml b/.github/workflows/pysat_rc.yml index 57113c3d..b6daa878 100644 --- a/.github/workflows/pysat_rc.yml +++ b/.github/workflows/pysat_rc.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.10"] + python-version: ["3.11"] # Keep this version at the highest supported Python version rc-package: ["pysat", "pysatNASA"] name: ${{ matrix.os }} with ${{ matrix.rc-package }} RC @@ -45,4 +45,17 @@ jobs: - name: Publish results to coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: coveralls --rcfile=setup.cfg --service=github + COVERALLS_PARALLEL: true + run: coveralls --rcfile=pyproject.toml --service=github + + finish: + name: Finish Coverage Analysis + needs: build + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install --upgrade coveralls + coveralls --service=github --finish diff --git a/docs/conf.py b/docs/conf.py index 4eed61d6..4deb4c35 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,6 +16,7 @@ import datetime as dt import json import os +import pkg_resources import sys sys.path.insert(0, os.path.abspath('..')) @@ -72,9 +73,7 @@ # # The short X.Y version. module_dir = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0] -version_file = os.path.join(module_dir, project, 'version.txt') -with open(version_file, 'r') as fin: - version = fin.read().strip() +version = pkg_resources.get_distribution('pysatModels').version # The full version, including alpha/beta/rc tags. release = '{:s}-alpha'.format(version) @@ -84,7 +83,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9db6e4a3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,74 @@ +[build-system] +requires = ["setuptools >= 38.6", "pip >= 10"] +build-backend = "setuptools.build_meta" + +[project] +name = "pysatModels" +version = "0.1.0" +description = "Supports model analysis and model-data comparisons" +readme = "README.md" +requires-python = ">=3.6" +license = {file = "LICENSE"} +authors = [ + {name = "Pysat Development Team", email = "pysat.developers@gmail.com"}, +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Topic :: Scientific/Engineering :: Physics", + "Intended Audience :: Science/Research", + "License :: Freely Distributable", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows" +] +dependencies = [ + "numpy", + "packaging", + "pandas", + "pyForecastTools", + "pysat >= 3.0.4", + "pysatNASA", + "requests", + "scipy", + "xarray" +] + +[project.optional-dependencies] +test = [ + "coveralls < 3.3", + "flake8", + "flake8-docstrings", + "hacking >= 1.0", + "pytest-cov", + "pytest-ordering" +] +doc = [ + "extras_require", + "m2r2", + "numpydoc", + "sphinx", + "sphinx_rtd_theme >= 1.2.2, < 2.0.0" +] + +[project.urls] +Documentation = "https://pysatmodels.readthedocs.io/en/latest/" +Source = "https://github.com/pysat/pysatModels" + +[tool.coverage.report] + +[tool.pytest.ini_options] +addopts = "--cov=pysatModels" +markers = [ + "all_inst", + "download", + "no_download", + "load_options", + "first", + "second" +] diff --git a/pysatModels/__init__.py b/pysatModels/__init__.py index dbef61b1..1ac1e5b4 100644 --- a/pysatModels/__init__.py +++ b/pysatModels/__init__.py @@ -10,17 +10,19 @@ """ +try: + from importlib import metadata +except ImportError: + import importlib_metadata as metadata + import logging -import os # Import key modules and skip F401 testing in flake8 from pysatModels import models # noqa: F401 from pysatModels import utils # noqa: F401 # Set the version -local_dir = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(local_dir, 'version.txt')) as version_file: - __version__ = version_file.read().strip() +__version__ = metadata.version('pysatModels') # Define a logger object to allow easier log handling logging.raiseExceptions = False @@ -30,4 +32,4 @@ logger.addHandler(handler) # Clean up variables -del handler, local_dir, version_file +del handler diff --git a/pysatModels/models/ucar_tiegcm.py b/pysatModels/models/ucar_tiegcm.py index 1bb827eb..738a8123 100644 --- a/pysatModels/models/ucar_tiegcm.py +++ b/pysatModels/models/ucar_tiegcm.py @@ -53,7 +53,8 @@ _test_dates = {'': {'': dt.datetime(2019, 1, 1), 'icon': dt.datetime(2020, 1, 10)}} -_test_download = {'': {'': False, 'icon': True}} +# TODO(#132): Turn on ICON download tests once pysatNASA 0.0.6 is released. +_test_download = {'': {'': False, 'icon': False}} _clean_warn = {'': {tag: general.clean_warn for tag in tags.keys()}} # ---------------------------------------------------------------------------- @@ -244,7 +245,10 @@ def download(date_array, tag, inst_id, data_path=None, **kwargs): if tag == '': warnings.warn('Not implemented, currently no support for Globus.') + # TODO(#132): Ensure new download routine is used after pysatNASA release. elif tag == 'icon': + warnings.warn('Not implemented, requires pysatNASA 0.0.6.') + elif tag == 'future_icon': # Set up temporary directory for zip files temp_dir = tempfile.TemporaryDirectory() diff --git a/pysatModels/tests/test_utils_convert.py b/pysatModels/tests/test_utils_convert.py index ce4ddf3e..142bff4a 100644 --- a/pysatModels/tests/test_utils_convert.py +++ b/pysatModels/tests/test_utils_convert.py @@ -66,10 +66,10 @@ class TestUtilsConvertLoadModelXarray(object): def setup_method(self): """Create a clean testing setup before each method.""" - self.ftime = pysat.instruments.pysat_testing_xarray._test_dates[''][''] + self.ftime = pysat.instruments.pysat_ndtesting._test_dates[''][''] self.filename = "%Y-%m-%d.nofile" self.model_kwargs = {'platform': str('pysat'), - 'name': str('testing_xarray'), + 'name': str('ndtesting'), 'num_samples': 12, 'clean_level': 'clean'} self.model_inst = None diff --git a/pysatModels/tests/test_utils_extract.py b/pysatModels/tests/test_utils_extract.py index 5cf9a9aa..ce81ef80 100644 --- a/pysatModels/tests/test_utils_extract.py +++ b/pysatModels/tests/test_utils_extract.py @@ -341,7 +341,7 @@ class TestUtilsExtractModObsXarray(TestUtilsExtractModObs): def setup_method(self): """Set up the unit test environment for each method.""" - self.inst = pysat.Instrument(platform='pysat', name='testing_xarray') + self.inst = pysat.Instrument(platform='pysat', name='ndtesting') self.model = pysat.Instrument(inst_module=pysat_testmodel, tag='') # Load the data in the instruments @@ -377,7 +377,7 @@ class TestUtilsExtractModObsXarray2D(TestUtilsExtractModObs): def setup_method(self): """Set up the unit test environment for each method.""" - self.inst = pysat.Instrument(platform='pysat', name='testing2d_xarray') + self.inst = pysat.Instrument(platform='pysat', name='ndtesting') self.model = pysat.Instrument(inst_module=pysat_testmodel, tag='') # Load the data in the instruments @@ -413,7 +413,7 @@ class TestUtilsExtractInstModViewXarray(TestUtilsExtractInstThroughMod): def setup_method(self): """Run before every method to create a clean testing setup.""" - self.inst = pysat.Instrument(platform='pysat', name='testing2d_xarray') + self.inst = pysat.Instrument(platform='pysat', name='ndtesting') self.model = pysat.Instrument(inst_module=pysat_testmodel) # Load the data in the instruments @@ -588,7 +588,7 @@ class TestUtilsAltitudePressureXarray(TestUtilsAltitudePressure): def setup_method(self): """Set up the unit test environment for each method.""" - self.inst = pysat.Instrument(platform='pysat', name='testing2d_xarray') + self.inst = pysat.Instrument(platform='pysat', name='ndtesting') self.model = pysat.Instrument(inst_module=pysat_testmodel, tag='pressure_levels') @@ -731,7 +731,7 @@ class TestUtilsExtractInstModIrregViewXarray(TestUtilsExtractInstModIrregView): def setup_method(self): """Run before every method to create a clean testing setup.""" - self.inst = pysat.Instrument(platform='pysat', name='testing2d_xarray', + self.inst = pysat.Instrument(platform='pysat', name='ndtesting', num_samples=3, max_latitude=45.) self.model = pysat.Instrument(inst_module=pysat_testmodel, tag='pressure_levels', diff --git a/pysatModels/tests/test_utils_testing.py b/pysatModels/tests/test_utils_testing.py index 67121924..9dc765e9 100644 --- a/pysatModels/tests/test_utils_testing.py +++ b/pysatModels/tests/test_utils_testing.py @@ -6,7 +6,6 @@ """Unit tests for `pysatModels.utils.testing`.""" import numpy as np -from packaging import version as pack_version import pytest import pysat @@ -25,9 +24,7 @@ def setup_method(self): # Load the data in the instruments load_kwargs = {'date': pysat_testmodel._test_dates['']['']} - if(pack_version.Version(pysat.__version__) - > pack_version.Version('3.0.1')): - load_kwargs['use_header'] = True + load_kwargs['use_header'] = True self.model.load(**load_kwargs) @@ -92,10 +89,6 @@ def test_compare_model_name_coordinates_failure(self, var, coords, msg, return -@pytest.mark.skipif(pack_version.Version(pysat.__version__) - <= pack_version.Version('3.0.1'), - reason=''.join(('Requires test model in pysat ', - ' v3.0.2 or later.'))) class TestUtilsCompareModNamePressure(TestUtilsCompareModName): """Unit tests for `compare_mod_name_coordinates`.""" @@ -107,9 +100,7 @@ def setup_method(self): # Load the data in the instruments load_kwargs = {'date': pysat_testmodel._test_dates['']['']} - if(pack_version.Version(pysat.__version__) - > pack_version.Version('3.0.1')): - load_kwargs['use_header'] = True + load_kwargs['use_header'] = True self.model.load(**load_kwargs) diff --git a/pysatModels/utils/extract.py b/pysatModels/utils/extract.py index f15b7c8c..6d3b037c 100644 --- a/pysatModels/utils/extract.py +++ b/pysatModels/utils/extract.py @@ -859,8 +859,8 @@ def extract_modelled_observations(inst, model, inst_name, mod_name, if mod_ind in mind and pair_method == 'closest': # Test to see if this model observation has multiple pairings old_ind = mind.index(mod_ind) - if(del_sec[inst_ind, mod_ind] - < del_sec[iind[old_ind], mind[old_ind]]): + if (del_sec[inst_ind, mod_ind] < del_sec[iind[old_ind], + mind[old_ind]]): # If this one is closer, keep it iind[old_ind] = inst_ind mind[old_ind] = mod_ind diff --git a/pysatModels/version.txt b/pysatModels/version.txt deleted file mode 100644 index 6e8bf73a..00000000 --- a/pysatModels/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/setup.cfg b/setup.cfg index df9c3d20..a83efd4a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,46 +1,6 @@ [metadata] name = pysatModels -version = file: pysatModels/version.txt -url = https://github.com/pysat/pysatModels -author = Pysat Development Team -author_email = pysat.developers@gmail.com -description = 'Supports model analysis and model-data comparisons' -long_description = file: README.md -long_description_content_type = text/markdown -classifiers = - Development Status :: 3 - Alpha - Topic :: Scientific/Engineering :: Physics - Intended Audience :: Science/Research - License :: Freely Distributable - Natural Language :: English - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Operating System :: MacOS :: MacOS X - Operating System :: POSIX :: Linux - Operating System :: Microsoft :: Windows -license_file = LICENSE - -[options] -python_requires = >= 3.6 -setup_requires = setuptools >= 38.6; pip >= 10 -packages = find: -include_package_data = True -zip_safe = False -install_requires = numpy - packaging - pandas - pyForecastTools - pysat - pysatNASA - scipy - xarray - -[coverage:run] - -[coverage:report] +version = 0.1.0 [flake8] max-line-length = 80 @@ -49,11 +9,3 @@ ignore = D202 H105 W503 - -[tool:pytest] -markers = - all_inst: tests all instruments - download: tests for downloadable instruments - no_download: tests for instruments without download support - first: first tests to run - second: second tests to run