Processes¶
This section deals with the creation of new Processes to be exposed via the WPS interface.
Processes are simply Components
that implement the ProcessInterface. For general
information about Plugins/Components please refer to the Plugins
documentation.
Creating a new Process¶
As we already mentioned, Processes are Components:
from eoxserver.core import Component, implements
from eoxserver.services.ows.wps.interfaces import ProcessInterface
class ExampleProcess(Component):
implements(ProcessInterface)
...
Apart from some optional metadata and a mandatory identifier, each Process has specific input parameters and output items. Those can be of various formats and complexity. Each input and output must be declared in the processes section. Let’s start with a simple example, using LiteralData inputs and outputs:
from eoxserver.services.ows.wps.parameters import LiteralData
class ExampleProcess(Component):
implements(ProcessInterface)
identifier = "ExampleProcess"
title = "Example Title."
metadata = {"example-metadata": "http://www.metadata.com/example-metadata"}
profiles = ["example_profile"]
inputs = [
("example_input", LiteralData(
'example_input', str, optional=True,
abstract="Example string input.",
))
]
outputs = [
("example_output", LiteralData(
'example_output', str,
abstract="Example string output.", default="n/a"
)),
]
...
LiteralData
inputs will always try to parse the input to the defined type. E.g: if you
defined your input type to float, an error will be raised if the supplied
parameters could not be passed. On the other hand, all your outputs will be
properly encoded and even translated to a specific unit if requested. Your
execute function will not need to hassle with type conversions of any kind for
your inputs/outputs.
Now that we have defined a Process with metadata, inputs and outputs we can
start writing the execute method of our Process. Each input parsed before it
is passed to our execute method where it is mapped to a named parameter
Our execute method is expected to return either a normal Python object if
we only declared a single output, or a dict of outputs where the
keys are the names of our declared outputs:
class ExampleProcess(Component):
implements(ProcessInterface)
...
inputs = [
("example_input", LiteralData(
'example_input', str, optional=True,
abstract="Example string input.",
))
]
outputs = [
("example_output", LiteralData(
'example_output', str,
abstract="Example string output.", default="n/a"
)),
]
def execute(self, **inputs):
outputs = {}
outputs["example_output"] = "Echo '%s'" % inputs["example_input"]
return outputs
Another often used type for Processes are BoundingBoxes. They are declared as
follows:
from eoxserver.core import Component, implements
from eoxserver.services.ows.wps.interfaces import ProcessInterface
from eoxserver.services.ows.wps.parameters import (
BoundingBoxData, BoundingBox
)
class ExampleProcess(Component):
implements(ProcessInterface)
...
inputs = [
("example_bbox_input", BoundingBoxData(
"example_bbox_input", crss=(4326, 3857),
default=BoundingBox([[-90, -180], [+90, +180]]),
)),
]
outputs = [
("example_bbox_output", BoundingBoxData(
"example_bbox_output", crss=(4326, 0)
)),
]
...
The third kind of input and output is ComplexData which can come in various formats,
binary or textual representation and either raw or base64 encoding.