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.
See the example for a complete implementation of this library for creating a demo plugin.
- Define a main function with the following signature:
# my_module.py
def main(params: dict) -> dict:
pass
- 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 arequired
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"]}
- Create a new file importing the
main
function above and thePLUGIN_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)
- Containerize your python code including the file created in 3. See
build_and_test_plugin.sh
in theexample
for details.