Skip to content

Commit

Permalink
Merge pull request #1 from pySTEPS/cookiecutter_testing
Browse files Browse the repository at this point in the history
Name changed from postprocessors to diagnostics
  • Loading branch information
joeycasey87 authored Aug 1, 2024
2 parents 708a3ba + 03cdeaa commit d90ca83
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 131 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
python-version: [ "3.6", "3.8" ]
os: [ "ubuntu-latest", "windows-latest" ]
python-version: [ "3.11" ]
max-parallel: 6

steps:
Expand All @@ -30,26 +30,26 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Install pysteps on MacOS
if: matrix.os == 'macos-latest'
working-directory: ${{github.workspace}}
env:
CC: gcc-9
CXX: g++-9
CXX1X: g++-9
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew update-reset
brew update
brew install gcc@9
gcc-9 --version
pip install git+https://github.com/pySTEPS/pysteps@importer_plugins_support
python -c "import pysteps"
# - name: Install pysteps on MacOS
# if: matrix.os == 'macos-latest'
# working-directory: ${{github.workspace}}
# env:
# CC: gcc-9
# CXX: g++-9
# CXX1X: g++-9
# HOMEBREW_NO_INSTALL_CLEANUP: 1
# run: |
# brew update-reset
# brew update
# brew install gcc@9
# gcc-9 --version
# pip install git+https://github.com/pySTEPS/pysteps
# python -c "import pysteps"

- name: Install pysteps on Windows and Linux
if: matrix.os != 'macos-latest'
run: |
pip install git+https://github.com/pySTEPS/pysteps@importer_plugins_support
pip install git+https://github.com/pySTEPS/pysteps
python -c "import pysteps"
- name: Run tests
Expand Down
61 changes: 60 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
Insert license information here
------------------------------------------------------------------------------------------
License for cookiecutter-pysteps-plugin

Copyright (c) 2020 Pysteps Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Audrey Roy Greenfeld nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

------------------------------------------------------------------------------------------
Cookiecutter-pypackage license

Copyright (c) 2020 Audrey Roy Greenfeld and individual contributors.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Audrey Roy Greenfeld nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. IMPORTANT::
The plugins support in pysteps is only available for versions >=1.4.

Cookiecutter Pysteps-postprocessing-plugin
Cookiecutter Pysteps-diagnostics-plugin
===========================

.. README_BEGIN_TAG
Cookiecutter template for Pysteps postprocessing plugins.
Cookiecutter template for Pysteps diagnostic postprocessing plugins.
Cookiecutter_ is a command-line utility to creates python packages projects from
templates, called "cookiecutters."

Expand All @@ -17,10 +17,10 @@ templates, called "cookiecutters."
How do the plugins work?
========================

When the plugin is installed, it advertises the new postprocessors to other packages
When the plugin is installed, it advertises the new diagnostic postprocessors to other packages
(in our case, pysteps) using the python `entry points specification`_.
These new postprocessors are automatically discovered every time that the pysteps library is
imported. The discovered postprocessors are added as attributes to the postprocessing.processors module
These new diagnostic postprocessors are automatically discovered every time that the pysteps library is
imported. The discovered diagnostic postprocessors are added as attributes to the postprocessing.diagnostics module
and registered to the postprocessing.get_method interface without any user intervention.
In addition, since the plugins' installation does not modify the actual pysteps
installation (i.e., the pysteps sources), the pysteps library can be updated without
Expand All @@ -37,7 +37,7 @@ Install the latest Cookiecutter::

To generate a skeleton for a Pysteps plugin in the current folder, simply run::

cookiecutter https://github.com/pysteps/cookiecutter-pysteps-postprocessing-plugin
cookiecutter https://github.com/pysteps/cookiecutter-pysteps-diagnostics-plugin

The above command will prompt the user to enter the following values used to generate
a skeleton for the plugin package:
Expand All @@ -49,7 +49,7 @@ a skeleton for the plugin package:
The name should be Python import friendly (no spaces, no hyphens, and no
special characters).
- **project_short_description**: Short description of the plugin.
- **postprocessor_name**: Name of the module implementing the postprocessors.
- **diagnostic_name**: Name of the module implementing the diagnostic postprocessors.
- **version**: The starting version number for your project.
- **open_source_license**. Choose a license for your project.
Options: [1. MIT License, 2. BSD license, 3. ISC license, 4. Apache Software License
Expand Down
6 changes: 3 additions & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"full_name": "Your Name",
"email": "[email protected]",
"project_name": "pysteps-postprocessor-xxx",
"project_name": "pysteps-diagnostic-xxx",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
"project_short_description": "Pysteps plugin adding XXX postprocessing functionality.",
"postprocessor_name": "postprocessor_xxx",
"project_short_description": "Pysteps plugin adding XXX diagnostic postprocessing functionality.",
"diagnostic_name": "diagnostic_xxx",
"version": "0.1.0",
"open_source_license": ["MIT license", "BSD license", "ISC license", "GNU General Public License v3", "Apache Software License 2.0", "Not open source"]
}
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
master_doc = 'index'

# General information about the project.
project = 'cookiecutter-pysteps-postprocessing-plugin'
project = 'cookiecutter-pysteps-diagnostics-plugin'
copyright = '2024, Pysteps developers'
author = 'Pysteps developers'

Expand Down
60 changes: 30 additions & 30 deletions docs/create_your_own_plugin.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
.. _create_your_own_plugin:

===============================
Create your own postprocessor plugin
Create your own diagnostic postprocessor plugin
===============================

Since version 1.11, pysteps allows the users to add new postprocessors by installing external
Since version 1.11, pysteps allows the users to add new diagnostic postprocessors by installing external
packages, called plugins, without modifying the pysteps installation. These plugins need
to follow a particular structure (described next) to allow pysteps to discover and
integrate the new postprocessors to the pysteps interface without any user intervention.
integrate the new diagnostic postprocessors to the pysteps interface without any user intervention.
For a short description of how the plugins work, see :ref:`how_plugins_work`.
There are two ways of creating your plugin. The first one involves building the plugin
from scratch. An easier alternative is using a Cookiecutter template that easily builds
the skeleton for the new importer plugin.

There are two ways of creating a plugin. The first one is building the postprocessor plugin
There are two ways of creating a plugin. The first one is building the diagnostic postprocessor plugin
from scratch. However, an easier alternative is using this `Cookiecutter`_ template
to create the skeleton for the new postprocessor plugin, and then customize it.
to create the skeleton for the new diagnostic postprocessor plugin, and then customize it.
However, this can be a daunting task if you are creating your first plugin.
Hence, before customizing the cookiecutter template, let's review the main components of
the plugin architecture by describing how to build a postprocessor plugin from scratch.
the plugin architecture by describing how to build a diagnostic postprocessor plugin from scratch.

After you are familiar with the plugin fundamentals, you can build your plugin from the
cookiecutter template. For a detailed description of the template, see
Expand All @@ -29,22 +29,22 @@ cookiecutter template. For a detailed description of the template, see
Minimal plugin project
----------------------

Let's suppose that we want to add a new postprocessor to pysteps. The name of the
postprocessor will be denoted as xxx.
Let's suppose that we want to add a new diagnostic postprocessor to pysteps. The name of the
diagnostic postprocessor will be denoted as xxx.

Without further ado, let's create a python package (a.k.a. the plugin) implementing the
postprocessor. For simplicity, we will only include the elements that are strictly
diagnostic postprocessor. For simplicity, we will only include the elements that are strictly
needed for the plugin to be installed and to work correctly.

The minimal python package to implement an postprocessor plugin has the following
The minimal python package to implement a diagnostic postprocessor plugin has the following
structure:

::

pysteps-postprocessor-xxx (project name)
├── pysteps_postprocessor_xxx (package name)
│ ├── postprocessor_xxx.py (importer module)
│ └── __init__.py (Initialize the pysteps_importer_abc package)
pysteps-diagnostic-xxx (project name)
├── pysteps_diagnostic_xxx (package name)
│ ├── diagnostic_xxx.py (diagnostic module)
│ └── __init__.py (Initialize the pysteps_diagnostic_xxx package)
├── setup.py (Build and installation script)
└── MANIFEST.in (manifest template)

Expand All @@ -53,31 +53,31 @@ Project name

::

pysteps-postprocessor-xxx (project name)
pysteps-diagnostic-xxx (project name)

For the project name, our example used the following convention:
**pysteps-postprocessor-<postprocessor short name>**.
**pysteps-diagnostic-<diagnostic short name>**.
Note that this convention is not strictly needed, and any name can be used.

Package name
~~~~~~~~~~~~

::

pysteps-postprocessor-xxx
└── pysteps_postprocessor_xxx (package name)
pysteps-diagnostic-xxx
└── pysteps_diagnostic_xxx (package name)

This is the name of our package containing the new postprocessor for pysteps.
This is the name of our package containing the new diagnostic postprocessor for pysteps.
The package name should not contain spaces, hyphens, or uppercase letters.
For our example, the package name is **pysteps_postprocessor_xxx**.
For our example, the package name is **pysteps_diagnostic_xxx**.

\__init__.py
~~~~~~~~~~~~

::

pysteps-postprocessor-xxx
├── pysteps_postprocessor_xxx
pysteps-diagnostic-xxx
├── pysteps_diagnostic_xxx
└───── __init__.py

The __init__.py files are required to inform python that a given directory contains a
Expand All @@ -89,15 +89,15 @@ Importer module

::

pysteps-postprocessor-xxx
├── pysteps_postprocessor_xxx
└───── postprocessor_xxx.py (postprocessor module)
pysteps-diagnostic-xxx
├── pysteps_diagnostic_xxx
└───── diagnostic_xxx.py (diagnostic module)

Inside the package folder (*pysteps_postprocessor_xxx*), we place the python module
(or modules) containing the actual implementation of our new postprocessor.
Below, there is an example of an postprocessor module that implements the skeleton of a postprocessor:
Inside the package folder (*pysteps_diagnostic_xxx*), we place the python module
(or modules) containing the actual implementation of our new diagnostic postprocessor.
Below, there is an example of a diagnostic postprocessor module that implements the skeleton of a diagnostic postprocessor:

.. literalinclude:: postprocessor_module_example.py
.. literalinclude:: diagnostic_module_example.py
:language: python


Expand All @@ -106,7 +106,7 @@ setup.py

::

pysteps-postprocessor-xxx (project name)
pysteps-diagnostic-xxx (project name)
└── setup.py (Build and installation script)

The `setup.py` file contains all the definitions for building, distributing, and
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.. _index:

======================================================
Welcome to cookiecutter-pysteps-postprocessing-plugin's documentation
Welcome to cookiecutter-pysteps-diagnostics-plugin's documentation
======================================================

.. include:: ../README.rst
:start-after: README_BEGIN_TAG
:end-before: README_END_TAG


Create your own postprocessor plugin
Create your own diagnostic postprocessor plugin
===============================

The previous section showed us how to quickly generate a template for our plugin.
The next step is to build your plugin, using the previous skeleton as an starting point.
However, this can be a daunting task if you are creating your first plugin.
To provide a easy-to-follow introduction to the plugin architecture, in the
:ref:`create_your_own_plugin` section we present a step-by-step guide creating,
from scratch, a minimal working example of a postprocessors plugin.
from scratch, a minimal working example of a diagnostic postprocessors plugin.
This tutorial explains in detail all the elements needed for the plugin to work correctly.

.. toctree::
Expand Down
Loading

0 comments on commit d90ca83

Please sign in to comment.