Skip to content

Commit 6976603

Browse files
authored
OAProc: add support for process execution (#940)
* OAProc: add support for process execution * fix WFS 1.1.0 logging
1 parent c16a6db commit 6976603

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

docs/source/usage.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ OGC API - Processes - Part 1: Core 1.0
341341
>>> hello_world['title']
342342
'Hello World'
343343
344+
>>> result = p.execute('hello-world', inputs={'name': 'World', 'message': 'Testing from OWSLib'})
345+
>>> result
346+
{'outputs': [{'id': 'echo', 'value': 'Hello World! Testing from OWSLib'}]}
347+
348+
344349
OGC API - Maps - Part 1: Core 1.0
345350
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346351

owslib/feature/wfs110.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def get_namespaces():
4848

4949
namespaces = get_namespaces()
5050

51+
LOGGER = logging.getLogger(__name__)
52+
5153

5254
class WebFeatureService_1_1_0(WebFeatureService_):
5355
"""Abstraction for OGC Web Feature Service (WFS).

owslib/ogcapi/processes.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,50 @@ def processes(self) -> list:
3434

3535
def process(self, process_id: str) -> dict:
3636
"""
37-
implements /processs/{processId}
37+
implements /processses/{processId}
3838
3939
@type process_id: string
4040
@param process_id: id of process
4141
42-
@returns: `dict` of process desceription
42+
@returns: `dict` of process description
4343
"""
4444

4545
path = f'processes/{process_id}'
4646
return self._request(path=path)
47+
48+
def execute(self, process_id: str, inputs: dict, outputs: dict = {},
49+
response: str = 'document', async_: bool = False) -> dict:
50+
"""
51+
implements /processes/{processId}/execution
52+
53+
@type process_id: string
54+
@param process_id: id of process
55+
@type data: string
56+
@param data: request payload
57+
@type inputs: inputs
58+
@param inputs: input parameters
59+
@type outputs: outputs
60+
@param outputs: output parameters
61+
@type async_: bool
62+
@param outputs: whether to execute request in asychronous mode
63+
64+
@returns: `dict` of response or URL reference to job
65+
"""
66+
67+
data = {}
68+
69+
if inputs:
70+
data['inputs'] = inputs
71+
if outputs:
72+
data['outputs'] = outputs
73+
74+
data['response'] = response
75+
76+
if async_:
77+
self.headers['Prefer'] = 'respond-async'
78+
else:
79+
self.headers['Prefer'] = 'respond-sync'
80+
81+
path = f'processes/{process_id}/execution'
82+
83+
return self._request(method='POST', path=path, data=data)

tests/test_ogcapi_processes_pygeoapi.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,18 @@ def test_ogcapi_processes_pygeoapi():
3434
hello_world = p.process('hello-world')
3535
assert hello_world['id'] == 'hello-world'
3636
assert hello_world['title'] == 'Hello World'
37+
38+
inputs = {
39+
'name': 'World',
40+
'message': 'Testing from OWSLib'
41+
}
42+
43+
execution = p.execute('hello-world', inputs=inputs)
44+
45+
assert execution['outputs'][0]['id'] == 'echo'
46+
assert execution['outputs'][0]['value'] == 'Hello World! Testing from OWSLib' # noqa
47+
48+
execution = p.execute('hello-world', inputs=inputs, response='raw')
49+
50+
assert execution['id'] == 'echo'
51+
assert execution['value'] == 'Hello World! Testing from OWSLib'

0 commit comments

Comments
 (0)