weaver.wps.service ================== .. py:module:: weaver.wps.service Module Contents --------------- .. py:data:: LOGGER .. py:class:: WorkerRequest(http_request: Optional[weaver.typedefs.AnyRequestType] = None, http_headers: Optional[weaver.typedefs.AnyHeadersCookieContainer] = None, **kwargs: Any) Extended :mod:`pywps` request with additional handling provided by :mod:`weaver`. .. py:attribute:: _auth_headers .. py:attribute:: auth_headers .. py:method:: parse_auth_headers(headers: Optional[weaver.typedefs.AnyHeadersCookieContainer]) -> werkzeug.datastructures.Headers .. py:class:: WorkerExecuteResponse(wps_request: WorkerRequest, uuid: str, process: pywps.app.Process, job_url: str, settings: weaver.typedefs.SettingsType, *_: Any, **__: Any) XML response generator from predefined job status URL and executed process definition. constructor :param pywps.app.WPSRequest.WPSRequest wps_request: :param pywps.app.Process.Process process: :param uuid: string this request uuid .. py:attribute:: store_status_file :value: True .. py:class:: WorkerService(*_, is_worker=False, settings=None, **__) Dispatches PyWPS requests from WPS-1/2 XML endpoint to WPS-REST as appropriate. .. note:: For every WPS-Request type, the parsing of XML content is already handled by the PyWPS service for GET/POST. All data must be retrieved from parsed :class:`WPSRequest` to avoid managing argument location and WPS versions. When ``GetCapabilities`` or ``DescribeProcess`` requests are received, directly return to result as XML based on content (no need to subprocess as Celery task that gets resolved quickly with only the process(es) details). When JSON content is requested, instead return the redirect link to corresponding WPS-REST API endpoint. When receiving ``Execute`` request, convert the XML payload to corresponding JSON and dispatch it to the Celery Worker to actually process it after job setup for monitoring. .. py:attribute:: is_worker :value: False .. py:attribute:: settings .. py:attribute:: dispatched_processes :type: Dict[str, weaver.datatype.Process] .. py:method:: _get_capabilities_redirect(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) -> Optional[Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid]] Redirects to WPS-REST endpoint if requested ``Content-Type`` is JSON. .. py:method:: get_capabilities(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) -> Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid] Handles the ``GetCapabilities`` KVP/XML request submitted on the WPS endpoint. Redirects to WPS-REST endpoint if requested ``Content-Type`` is JSON or handle ``GetCapabilities`` normally. .. py:method:: _describe_process_redirect(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) -> Optional[Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid]] Redirects to WPS-REST endpoint if requested ``Content-Type`` is JSON. .. py:method:: describe(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) -> Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid] Handles the ``DescribeProcess`` KVP/XML request submitted on the WPS endpoint. Redirect to WPS-REST endpoint if requested ``Content-Type`` is JSON or handle ``DescribeProcess`` normally. .. py:method:: _submit_job(wps_request: pywps.app.WPSRequest) -> Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid, weaver.typedefs.JSON] Dispatch operation to WPS-REST endpoint, which in turn should call back the real Celery Worker for execution. Returns the status response as is if XML, or convert it to JSON, according to request ``Accept`` header. .. py:method:: create_complex_inputs(source: pywps.inout.basic.ComplexInput, inputs: List[Dict[str, str]]) -> Deque[pywps.inout.basic.ComplexInput] Dynamically adjust process input definitions to align with unrestricted format as applicable. Due to how :meth:`create_complex_inputs` of :mod:`pywps` is implemented (check of format by ``[0]`` index), a ``supported_formats`` property must always contain at least 1 format. However, that restriction erroneously rejects an "any" :term:`Media-Type` input that does not enforce a specific format (i.e.: ``text/plain`` and ``*/*`` by default). Therefore, update the input dynamically to inject the missing formats matching submitted inputs to make them succeed the validation transparently. Without this patch, a submitted input trying to be more informative about its content by advertising its actual :term:`Media-Type`, schema, encoding, etc. gets penalized over an input "just" submitting the complex data/file reference. .. py:method:: prepare_process_for_execution(identifier: str) -> pywps.app.Process Handles dispatched remote provider process preparation during execution request. .. py:method:: execute(identifier: str, wps_request: Union[pywps.app.WPSRequest, WorkerRequest], uuid: str) -> Union[pywps.response.basic.WPSResponse, weaver.typedefs.HTTPValid] Handles the ``Execute`` :term:`KVP`/:term:`XML` request submitted on the :term:`WPS` endpoint. Submit :term:`WPS` request to corresponding :term:`WPS-REST` endpoint and convert back for requested ``Accept`` content-type. Overrides the original execute operation, that will instead be handled by :meth:`execute_job` following callback from :mod:`celery` worker, which handles :term:`Job` creation and monitoring. If ``Accept`` is :term:`JSON`, the result is directly returned from :meth:`_submit_job`. If ``Accept`` is :term:`XML` or undefined, :class:`WorkerExecuteResponse` converts the received :term:`JSON` with :term:`XML` template. .. py:method:: execute_job(job: weaver.datatype.Job, wps_inputs: List[weaver.typedefs.WPS_InputData], wps_outputs: List[weaver.typedefs.WPS_OutputRequested], remote_process: Optional[weaver.datatype.Process], headers: Optional[weaver.typedefs.AnyHeadersCookieContainer]) -> owslib.wps.WPSExecution Real execution of the process by active Celery Worker. .. py:function:: get_pywps_service(environ: weaver.typedefs.SettingsType = None, is_worker: bool = False) -> WorkerService Generates the PyWPS Service that provides WPS-1/2 XML endpoint.