Skip to content

Commit

Permalink
Merge pull request #137 from pysat/maint/pyproject
Browse files Browse the repository at this point in the history
MAINT: pyproject, pysat style updates
  • Loading branch information
jklenzing authored Jan 17, 2024
2 parents a77c2c9 + 4ce2fda commit 1267042
Show file tree
Hide file tree
Showing 22 changed files with 205 additions and 108 deletions.
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
50 changes: 39 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10"]
numpy_ver: [latest]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11"]
numpy_ver: ["latest"]
test_config: ["latest"]
include:
- python-version: "3.8"
numpy_ver: "1.20.3"
os: "ubuntu-latest"
- python-version: "3.9"
numpy_ver: "1.22"
os: ubuntu-latest
test_config: "NEP29"
- python-version: "3.6.8"
numpy_ver: "1.19.5"
os: "ubuntu-20.04"
test_config: "Ops"

name: Python ${{ matrix.python-version }} on ${{ matrix.os }} with numpy ${{ matrix.numpy_ver }}
runs-on: ${{ matrix.os }}
Expand All @@ -29,15 +35,24 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install standard dependencies
- name: Install Operational dependencies
if: ${{ matrix.test_config == 'Ops'}}
run: |
pip install -r test_requirements.txt
pip install --no-cache-dir numpy==${{ matrix.numpy_ver }}
pip install "cdflib<1.0"
pip install -r requirements.txt
pip install -r test_requirements.txt
pip install .
- name: Install NEP29 dependencies
if: ${{ matrix.numpy_ver != 'latest'}}
if: ${{ matrix.test_config == 'NEP29'}}
run: |
pip install numpy==${{ matrix.numpy_ver }}
pip install --upgrade-strategy only-if-needed .[test]
- name: Install standard dependencies
if: ${{ matrix.test_config == 'latest'}}
run: pip install .[test]

- name: Set up pysat
run: |
Expand All @@ -51,9 +66,22 @@ jobs:
run: flake8 . --count --exit-zero --max-complexity=10 --statistics

- name: Run unit and integration tests
run: pytest --cov=pysatModels/
run: pytest

- 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
23 changes: 17 additions & 6 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 All @@ -30,19 +30,30 @@ jobs:
run: pip install --no-deps --pre -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ${{ matrix.rc-package }}

- name: Install standard dependencies
run: |
pip install -r test_requirements.txt
pip install -r requirements.txt
run: pip install .[test]

- name: Set up pysat
run: |
mkdir pysatData
python -c "import pysat; pysat.params['data_dirs'] = 'pysatData'"
- name: Run unit and integration tests
run: pytest --cov=pysatModels/
run: pytest

- 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
25 changes: 25 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py


# Optionally declare the Python requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- doc
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Updated tests to new pysat and pytest standards
* Added a cap for pysatNASA
* Removed backwards-support for pysat pre-3.0.4 functions
* Updated to use pyproject
* Added yaml for readthedocs
* Documentation
* Added badges and instructions for PyPi and Zenodo

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ the Space Physics community. This module officially supports Python 3.6+.
| Common modules | Community modules |
| ------------------ | ------------------ |
| numpy | pyForecastTools |
| pandas >= 1.4.0 | pysat >= 3.0.4 |
| pandas | pysat >= 3.0.4 |
| requests | pysatNASA <= 0.0.4 |
| scipy | |
| xarray | |
Expand Down
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
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Prerequisites
pysatModels uses common Python modules, as well as modules developed by and for
the Space Physics community. This module officially supports Python 3.6+.

============== =================
============== ==================
Common modules Community modules
============== =================
numpy pysat
pandas pysatNASA
============== ==================
numpy pysat >= 3.0.4
pandas pysatNASA <= 0.0.4
requests pyForecastTools
scipy
xarray
============== =================
============== ==================


.. _install-opt:
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ output, and incorporating modelled data sets into general data analysis
routines written to use data stored in
`pysat.Instrument <https://pysat.readthedocs.io/en/latest/api.html#instrument>`_
objects or
`xarray.Datasets <https://xarray.pydata.org/en/stable/generated/xarray.Dataset.html>`_.
`xarray.Datasets <https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html>`_.

.. image:: images/pysatModels.png
:width: 400px
Expand Down
75 changes: 75 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[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 <= 0.0.4",
"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",
"new_tests",
"first",
"second"
]
12 changes: 7 additions & 5 deletions pysatModels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
"""

import logging
import os

try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata

# 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
2 changes: 2 additions & 0 deletions pysatModels/models/pydineof_dineof.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

_test_dates = {'': {tag: dt.datetime(2009, 1, 1) for tag in tags.keys()}}
_test_download = {'': {'': False, 'test': True}}
# TODO(#136): Remove when compliant with multi-day load tests
_test_new_tests = {'': {'test': False}}

# ----------------------------------------------------------------------------
# Instrument methods
Expand Down
2 changes: 2 additions & 0 deletions pysatModels/models/sami2py_sami2.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

_test_dates = {'': {tag: dt.datetime(2019, 1, 1) for tag in tags.keys()}}
_test_download = {'': {'': False, 'test': True}}
# TODO(#136): Remove when compliant with multi-day load tests
_test_new_tests = {'': {'test': False}}

# ----------------------------------------------------------------------------
# Instrument methods
Expand Down
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}}

# ----------------------------------------------------------------------------
# Instrument methods
Expand Down Expand Up @@ -243,7 +244,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
Loading

0 comments on commit 1267042

Please sign in to comment.