Skip to content

Commit

Permalink
Merge pull request #588 from talos-gis/pywps-4.4-rest
Browse files Browse the repository at this point in the history
OGC API - Processes / REST API implementation
  • Loading branch information
cehbrecht authored Jun 9, 2021
2 parents 7112197 + 54c1b09 commit cd71ee7
Show file tree
Hide file tree
Showing 20 changed files with 667 additions and 175 deletions.
2 changes: 1 addition & 1 deletion pywps/app/Process.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _run_process(self, wps_request, wps_response):
if wps_response.status != WPS_STATUS.SUCCEEDED and wps_response.status != WPS_STATUS.FAILED:
# if (not wps_response.status_percentage) or (wps_response.status_percentage != 100):
LOGGER.debug('Updating process status to 100% if everything went correctly')
wps_response._update_status(WPS_STATUS.SUCCEEDED, 'PyWPS Process {} finished'.format(self.title), 100)
wps_response._update_status(WPS_STATUS.SUCCEEDED, f'PyWPS Process {self.title} finished', 100)
except Exception as e:
traceback.print_exc()
LOGGER.debug('Retrieving file and line number where exception occurred')
Expand Down
9 changes: 6 additions & 3 deletions pywps/app/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import logging
import tempfile
from typing import Sequence, Optional, Dict

from werkzeug.exceptions import HTTPException
from werkzeug.wrappers import Request, Response
from urllib.parse import urlparse
Expand Down Expand Up @@ -39,9 +41,10 @@ class Service(object):
:param cfgfiles: A list of configuration files
"""

def __init__(self, processes=[], cfgfiles=None):
def __init__(self, processes: Sequence = [], cfgfiles=None, preprocessors: Optional[Dict] = None):
# ordered dict of processes
self.processes = OrderedDict((p.identifier, p) for p in processes)
self.preprocessors = preprocessors or dict()

if cfgfiles:
config.load_configuration(cfgfiles)
Expand Down Expand Up @@ -85,7 +88,7 @@ def prepare_process_for_execution(self, identifier):
process = self.processes[identifier]
except KeyError:
raise InvalidParameterValue("Unknown process '{}'".format(identifier), 'Identifier')
# make deep copy of the process instace
# make deep copy of the process instance
# so that processes are not overriding each other
# just for execute
process = copy.deepcopy(process)
Expand Down Expand Up @@ -281,7 +284,7 @@ def call(self, http_request):
LOGGER.debug('Setting PYWPS_CFG to {}'.format(environ_cfg))
os.environ['PYWPS_CFG'] = environ_cfg

wps_request = WPSRequest(http_request)
wps_request = WPSRequest(http_request, self.preprocessors)
LOGGER.info('Request: {}'.format(wps_request.operation))
if wps_request.operation in ['getcapabilities',
'describeprocess',
Expand Down
Loading

0 comments on commit cd71ee7

Please sign in to comment.