From 263302f7117a3abb3cc0af21a2c91a7bb563ccfb Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 4 Jul 2023 10:47:23 -0400 Subject: [PATCH 1/3] add DISCLAIMER and import modules in __init__.py to ease importing in TP apps --- README.md | 15 +++++++++++++++ src/wxflow/__init__.py | 15 ++++++++++++++- src/wxflow/logger.py | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbc7f85..588bbdc 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,18 @@ $> source venv/bin/activate # Run pytests (venv) $> pytest -v ``` + +# Disclaimer + +The United States Department of Commerce (DOC) GitHub project code is provided +on an "as is" basis and the user assumes responsibility for its use. DOC has +relinquished control of the information and no longer has responsibility to +protect the integrity, confidentiality, or availability of the information. Any +claims against the Department of Commerce stemming from the use of its GitHub +project will be governed by all applicable Federal law. Any reference to +specific commercial products, processes, or services by service mark, +trademark, manufacturer, or otherwise, does not constitute or imply their +endorsement, recommendation or favoring by the Department of Commerce. The +Department of Commerce seal and logo, or the seal and logo of a DOC bureau, +shall not be used in any manner to imply endorsement of any commercial product +or activity by DOC or the United States Government. diff --git a/src/wxflow/__init__.py b/src/wxflow/__init__.py index 13f56fe..76836cc 100644 --- a/src/wxflow/__init__.py +++ b/src/wxflow/__init__.py @@ -1,6 +1,19 @@ """ -Commonly used toolset for the global applications and beyond. +Commonly used toolset in weather workflow applications. """ +from .yaml_file import YAMLFile, parse_yaml, parse_yamltmpl, parse_j2yaml, save_as_yaml, dump_as_yaml, vanilla_yaml +from .timetools import * +from .template import TemplateConstants, Template +from .task import Task +from .logger import Logger, logit +from .jinja import Jinja +from .fsutils import mkdir, mkdir_p, rmdir, chdir, rm_p, cp +from .file_utils import FileHandler +from .factory import Factory +from .executable import Executable, which, CommandNotFoundError +from .exceptions import WorkflowException, msg_except_handle +from .configuration import Configuration, cast_strdict_as_dtypedict, cast_as_dtype +from .attrdict import AttrDict __docformat__ = "restructuredtext" import os diff --git a/src/wxflow/logger.py b/src/wxflow/logger.py index 1bf2ed2..b12aef8 100644 --- a/src/wxflow/logger.py +++ b/src/wxflow/logger.py @@ -9,6 +9,8 @@ from typing import Union, List import logging +__all__ = ['Logger', 'logit'] + class ColoredFormatter(logging.Formatter): """ From 6b81a6ce2206918fe215b93db7e0dddd6d8d66d7 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 5 Jul 2023 18:18:00 -0400 Subject: [PATCH 2/3] prepare to publish --- .github/workflows/release.yaml | 33 ++++++++++++++++++ README.md | 16 ++------- pyproject.toml | 46 ------------------------ setup.cfg | 64 ++++++++++++++++++++++++++++++++++ setup.py | 4 +++ src/wxflow/__init__.py | 10 +++--- 6 files changed, 107 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..32a53f1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: Publish Python distributions to PyPI + +on: + release: + types: [published] + +jobs: + build-and-publish: + name: Build and publish Python distribution to PyPI + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install pypa/build + run: | + python3 -m pip install build --user + + - name: Build a binary wheel and a source tarball + run: | + python3 -m build --sdist --wheel --outdir dist/ . + + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/README.md b/README.md index 588bbdc..edcb65c 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,15 @@ [![pynorms](https://github.com/NOAA-EMC/wxflow/actions/workflows/pynorms.yaml/badge.svg)](https://github.com/NOAA-EMC/wxflow/actions/workflows/pynorms.yaml) [![pytests](https://github.com/NOAA-EMC/wxflow/actions/workflows/pytests.yaml/badge.svg)](https://github.com/NOAA-EMC/wxflow/actions/workflows/pytests.yaml) +![PyPI](https://img.shields.io/pypi/v/:wxflow) # Tools for Weather Workflows Common set of tools used in weather workflows ## Installation -Simple installation instructions ```sh -$> git clone https://github.com/noaa-emc/wxflow -$> cd wxflow -$> pip install . -``` - -It is not required to install this package. Instead, -```sh -$> cd wxflow -$> export PYTHONPATH=${PWD}/src/wxflow +$> pip install wxflow ``` -would put this package in the `PYTHONPATH` - -### Note: -These instructions will be updated and the tools are under development. ### Running python tests: Simple instructions to enable executing pytests manually diff --git a/pyproject.toml b/pyproject.toml index 3b46d9b..9787c3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,49 +1,3 @@ -[project] -name = "wxflow" -version = "0.1.0" -description = "Tools for Weather Workflows" -readme = "README.md" -requires-python = ">=3.6" -license = {file = "LICENSE.md"} -keywords = ["NWP", "Workflow"] -authors = [ - {name = "NOAA/NWS/NCEP/EMC", email = "First.Last@noaa.gov" } -] -maintainers = [ - {name = "NOAA/NWS/NCEP/EMC", email = "First.Last@noaa.gov" } -] - -classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU Lesser General Public License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3 :: Only", -] - -dependencies = [ - "numpy>=1.21.6", - "PyYAML>=6.0", - "Jinja2>=3.1.2" -] - -[project.optional-dependencies] -dev = ["check-manifest", "pytest>=7", "pytest-cov[all]"] -test = ["pytest>=7", "pytest-cov[all]"] -lint = ["pycodestyle"] - -[project.urls] -"Homepage" = "https://github.com/NOAA-EMC/wxflow" -"Bug Reports" = "https://github.com/NOAA-EMC/wxflow/issues" -"Source" = "https://github.com/NOAA-EMC/wxflow/" - [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2f9e124 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,64 @@ +[metadata] +name = wxflow +version = attr: wxflow.__version__ +description = Tools for Weather Workflows +long_description = file: README.md +long_description_content_type = text/markdown +author = NOAA/NWS/NCEP/EMC +#author_email = first.last@domain.tld +keywords = NOAA, NWS, NCEP, EMC +home_page = https://github.com/noaa-emc/wxflow +license = GNU Lesser General Public License v3 or later (LGPLv3+) +classifiers = + Development Status :: 4 - Beta + Intended Audience :: Developers + Intended Audience :: Science/Research + License :: OSI Approved :: GNU Lesser General Public License + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Topic :: Software Development :: Libraries :: Python Modules + Operating System :: OS Independent + Typing :: Typed +project_urls = + Bug Tracker = https://github.com/noaa-emc/wxflow/issues + CI = https://github.com/noaa-emc/wxflow/actions + +[options] +zip_safe = False +include_package_data = True +package_dir = + =src +packages = find_namespace: +python_requires = >= 3.6 +setup_requires = + setuptools +install_requires = + numpy>=1.22.0 + PyYAML>=6.0 + Jinja2>=3.1.2 +tests_require = + pytest + +[options.packages.find] +where=src + +[options.package_data] +* = *.txt, *.md + +[options.extras_require] +dev = pytest>=7; pytest-cov>=3 + +[green] +file-pattern = test_*.py +verbose = 2 +no-skip-report = true +quiet-stdout = true +run-coverage = true diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e748ce0 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +''' Standard file for building the package with Distutils. ''' + +import setuptools +setuptools.setup() diff --git a/src/wxflow/__init__.py b/src/wxflow/__init__.py index 76836cc..eccefa5 100644 --- a/src/wxflow/__init__.py +++ b/src/wxflow/__init__.py @@ -1,6 +1,5 @@ -""" -Commonly used toolset in weather workflow applications. -""" +import os + from .yaml_file import YAMLFile, parse_yaml, parse_yamltmpl, parse_j2yaml, save_as_yaml, dump_as_yaml, vanilla_yaml from .timetools import * from .template import TemplateConstants, Template @@ -14,8 +13,7 @@ from .exceptions import WorkflowException, msg_except_handle from .configuration import Configuration, cast_strdict_as_dtypedict, cast_as_dtype from .attrdict import AttrDict -__docformat__ = "restructuredtext" - -import os +__docformat__ = "restructuredtext" +__version__ = "0.1.0" wxflow_directory = os.path.dirname(__file__) From d44d6c5600ffab8efdf82583c17686ee48d3f482 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 5 Jul 2023 18:21:51 -0400 Subject: [PATCH 3/3] move tests to top, add 3.11 in pytest CI --- .github/workflows/pytests.yaml | 4 ++-- setup.cfg | 3 +-- {src/tests => tests}/__init__.py | 0 {src/tests => tests}/test-files/test_schema.yaml | 0 {src/tests => tests}/test_configuration.py | 0 {src/tests => tests}/test_exceptions.py | 0 {src/tests => tests}/test_executable.py | 0 {src/tests => tests}/test_factory.py | 0 {src/tests => tests}/test_file_utils.py | 0 {src/tests => tests}/test_jinja.py | 0 {src/tests => tests}/test_logger.py | 0 {src/tests => tests}/test_schema.py | 0 {src/tests => tests}/test_template.py | 0 {src/tests => tests}/test_timetools.py | 0 {src/tests => tests}/test_yaml_file.py | 0 15 files changed, 3 insertions(+), 4 deletions(-) rename {src/tests => tests}/__init__.py (100%) rename {src/tests => tests}/test-files/test_schema.yaml (100%) rename {src/tests => tests}/test_configuration.py (100%) rename {src/tests => tests}/test_exceptions.py (100%) rename {src/tests => tests}/test_executable.py (100%) rename {src/tests => tests}/test_factory.py (100%) rename {src/tests => tests}/test_file_utils.py (100%) rename {src/tests => tests}/test_jinja.py (100%) rename {src/tests => tests}/test_logger.py (100%) rename {src/tests => tests}/test_schema.py (100%) rename {src/tests => tests}/test_template.py (100%) rename {src/tests => tests}/test_timetools.py (100%) rename {src/tests => tests}/test_yaml_file.py (100%) diff --git a/.github/workflows/pytests.yaml b/.github/workflows/pytests.yaml index b2e8722..f1facb5 100644 --- a/.github/workflows/pytests.yaml +++ b/.github/workflows/pytests.yaml @@ -7,7 +7,7 @@ jobs: name: Install wxflow and run tests with pytests strategy: matrix: - python: ["3.7", "3.8", "3.9", "3.10"] + python: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - name: Setup Python @@ -30,4 +30,4 @@ jobs: - name: Run pytests run: | cd $GITHUB_WORKSPACE - pytest -v src/tests + pytest -v diff --git a/setup.cfg b/setup.cfg index 2f9e124..b2dfcf0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,6 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -41,7 +40,7 @@ python_requires = >= 3.6 setup_requires = setuptools install_requires = - numpy>=1.22.0 + numpy>=1.21.6 PyYAML>=6.0 Jinja2>=3.1.2 tests_require = diff --git a/src/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/tests/__init__.py rename to tests/__init__.py diff --git a/src/tests/test-files/test_schema.yaml b/tests/test-files/test_schema.yaml similarity index 100% rename from src/tests/test-files/test_schema.yaml rename to tests/test-files/test_schema.yaml diff --git a/src/tests/test_configuration.py b/tests/test_configuration.py similarity index 100% rename from src/tests/test_configuration.py rename to tests/test_configuration.py diff --git a/src/tests/test_exceptions.py b/tests/test_exceptions.py similarity index 100% rename from src/tests/test_exceptions.py rename to tests/test_exceptions.py diff --git a/src/tests/test_executable.py b/tests/test_executable.py similarity index 100% rename from src/tests/test_executable.py rename to tests/test_executable.py diff --git a/src/tests/test_factory.py b/tests/test_factory.py similarity index 100% rename from src/tests/test_factory.py rename to tests/test_factory.py diff --git a/src/tests/test_file_utils.py b/tests/test_file_utils.py similarity index 100% rename from src/tests/test_file_utils.py rename to tests/test_file_utils.py diff --git a/src/tests/test_jinja.py b/tests/test_jinja.py similarity index 100% rename from src/tests/test_jinja.py rename to tests/test_jinja.py diff --git a/src/tests/test_logger.py b/tests/test_logger.py similarity index 100% rename from src/tests/test_logger.py rename to tests/test_logger.py diff --git a/src/tests/test_schema.py b/tests/test_schema.py similarity index 100% rename from src/tests/test_schema.py rename to tests/test_schema.py diff --git a/src/tests/test_template.py b/tests/test_template.py similarity index 100% rename from src/tests/test_template.py rename to tests/test_template.py diff --git a/src/tests/test_timetools.py b/tests/test_timetools.py similarity index 100% rename from src/tests/test_timetools.py rename to tests/test_timetools.py diff --git a/src/tests/test_yaml_file.py b/tests/test_yaml_file.py similarity index 100% rename from src/tests/test_yaml_file.py rename to tests/test_yaml_file.py