Skip to content

Dewberry/papipyplug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

papipyplug

Process-API Python Plugin

A lightweight wrapper for converting python functions into plugins for use in the process-api implementation of the OGC API-Proceses standard.


Usage

See the example for a complete implementation of this library for creating a demo plugin.

  1. Define a main function with the following signature:
# my_module.py
def main(params: dict) -> dict:
    pass
  1. Add a constant PLUGIN_PARAMS describing the params that are required and/or optional to for the main function. the dictionary must, at a minimum, contain a required key returning a list of parameters for the funcion to recieve on execution.
# my_module.py
PLUGIN_PARAMS = {"required": ["first_param", "second_param"], "optional": ["additioan_param"]}
  1. Create a new file importing the main function above and the PLUGIN_PARAMS. Format the script to use the utilities from this library to prepare the data and format the results:
import sys

from .my_module import  main, PLUGIN_PARAMS

from papipyplug import parse_input, print_results, plugin_logger, git_meta

if __name__ == "__main__":
    # Start plugin logger
    plugin_logger()

    # Read, parse, and verify input parameters
    input_params = parse_input(sys.argv, PLUGIN_PARAMS)

    # Add main function here
    results = main(input_params)

    # Print Results
    print_results(results)
  1. Containerize your python code including the file created in 3. See build_and_test_plugin.sh in the example for details.

About

Python plugin utilities for the process-api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published