Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG/MAINT: pyproject, workflow updates, pysatNASA temporary fixes #135

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
17 changes: 15 additions & 2 deletions .github/workflows/pysat_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
7 changes: 3 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import datetime as dt
import json
import os
import pkg_resources
import sys

sys.path.insert(0, os.path.abspath('..'))
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
]
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"
]
12 changes: 7 additions & 5 deletions pysatModels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,4 +32,4 @@
logger.addHandler(handler)

# Clean up variables
del handler, local_dir, version_file
del handler
6 changes: 5 additions & 1 deletion pysatModels/models/ucar_tiegcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}}

# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions pysatModels/tests/test_utils_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pysatModels/tests/test_utils_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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',
Expand Down
13 changes: 2 additions & 11 deletions pysatModels/tests/test_utils_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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`."""

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pysatModels/utils/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pysatModels/version.txt

This file was deleted.

Loading
Loading