Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def execute_process(api: API, request: APIRequest,
'type': 'process',
'status': status.value
}
response2 = to_json(response2, pretty_print_)

if api.pubsub_client is not None:
LOGGER.debug('Publishing message')
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/process/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def execute(self, data: dict, outputs: Optional[dict] = None
The value of any key may be an object and include the
property `transmissionMode` - defaults to `value`.
:returns: tuple of MIME type and process response
(string or bytes, or dict)
(string, bytes, list or dict)
"""

raise NotImplementedError()
Expand Down
7 changes: 7 additions & 0 deletions pygeoapi/process/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
current_status = JobStatus.running
jfmt, outputs = p.execute(data_dict, **extra_execute_parameters)

if isinstance(outputs, bytes):
outputs = outputs.decode('utf-8')

if requested_response == RequestedResponse.document.value:
outputs = {
'outputs': [outputs]
Expand All @@ -299,6 +302,10 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
mode = 'wb'
data = outputs
encoding = None
elif isinstance(outputs, str):
mode = 'w'
data = outputs
encoding = None
with job_filename.open(mode=mode, encoding=encoding) as fh:
fh.write(data)

Expand Down
4 changes: 3 additions & 1 deletion tests/api/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ def test_execute_process(config, api_):
req = mock_api_request(data=req_body_1, HTTP_Prefer='respond-async')
rsp_headers, code, response = execute_process(api_, req, 'hello-world')

assert 'Location' in rsp_headers
response = json.loads(response)
assert code == HTTPStatus.CREATED

assert 'Location' in rsp_headers
assert isinstance(response, dict)
assert 'jobID' in response
assert 'type' in response
Expand Down