weaver.wps.service
Module Contents
- class weaver.wps.service.WorkerRequest(http_request: weaver.typedefs.AnyRequestType | None = None, http_headers: weaver.typedefs.AnyHeadersCookieContainer | None = None, **kwargs: Any)[source]
Extended
pywpsrequest with additional handling provided byweaver.
- class weaver.wps.service.WorkerExecuteResponse(wps_request: WorkerRequest, uuid: str, process: pywps.app.Process, job_url: str, settings: weaver.typedefs.SettingsType, *_: Any, **__: Any)[source]
XML response generator from predefined job status URL and executed process definition.
constructor
- Parameters:
wps_request (pywps.app.WPSRequest.WPSRequest)
process (pywps.app.Process.Process)
uuid – string this request uuid
- class weaver.wps.service.WorkerService(*_, is_worker=False, settings=None, **__)[source]
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
WPSRequestto avoid managing argument location and WPS versions.When
GetCapabilitiesorDescribeProcessrequests 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
Executerequest, convert the XML payload to corresponding JSON and dispatch it to the Celery Worker to actually process it after job setup for monitoring.- dispatched_processes: Dict[str, weaver.datatype.Process][source]
- _get_capabilities_redirect(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid | None[source]
Redirects to WPS-REST endpoint if requested
Content-Typeis JSON.
- get_capabilities(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid[source]
Handles the
GetCapabilitiesKVP/XML request submitted on the WPS endpoint.Redirects to WPS-REST endpoint if requested
Content-Typeis JSON or handleGetCapabilitiesnormally.
- _describe_process_redirect(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid | None[source]
Redirects to WPS-REST endpoint if requested
Content-Typeis JSON.
- describe(wps_request: pywps.app.WPSRequest, *_: Any, **__: Any) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid[source]
Handles the
DescribeProcessKVP/XML request submitted on the WPS endpoint.Redirect to WPS-REST endpoint if requested
Content-Typeis JSON or handleDescribeProcessnormally.
- _submit_job(wps_request: pywps.app.WPSRequest) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid | weaver.typedefs.JSON[source]
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
Acceptheader.
- create_complex_inputs(source: pywps.inout.basic.ComplexInput, inputs: List[Dict[str, str]]) Deque[pywps.inout.basic.ComplexInput][source]
Dynamically adjust process input definitions to align with unrestricted format as applicable.
Due to how
create_complex_inputs()ofpywpsis implemented (check of format by[0]index), asupported_formatsproperty must always contain at least 1 format. However, that restriction erroneously rejects an “any” Media-Type input that does not enforce a specific format (i.e.:text/plainand*/*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 Media-Type, schema, encoding, etc. gets penalized over an input “just” submitting the complex data/file reference.
- prepare_process_for_execution(identifier: str) pywps.app.Process[source]
Handles dispatched remote provider process preparation during execution request.
- execute(identifier: str, wps_request: pywps.app.WPSRequest | WorkerRequest, uuid: str) pywps.response.basic.WPSResponse | weaver.typedefs.HTTPValid[source]
Handles the
ExecuteKVP/XML request submitted on the WPS endpoint.Submit WPS request to corresponding WPS-REST endpoint and convert back for requested
Acceptcontent-type.Overrides the original execute operation, that will instead be handled by
execute_job()following callback fromceleryworker, which handles Job creation and monitoring.If
Acceptis JSON, the result is directly returned from_submit_job(). IfAcceptis XML or undefined,WorkerExecuteResponseconverts the received JSON with XML template.
- execute_job(job: weaver.datatype.Job, wps_inputs: List[weaver.typedefs.WPS_InputData], wps_outputs: List[weaver.typedefs.WPS_OutputRequested], remote_process: weaver.datatype.Process | None, headers: weaver.typedefs.AnyHeadersCookieContainer | None) owslib.wps.WPSExecution[source]
Real execution of the process by active Celery Worker.
- weaver.wps.service.get_pywps_service(environ: weaver.typedefs.SettingsType = None, is_worker: bool = False) WorkerService[source]
Generates the PyWPS Service that provides WPS-1/2 XML endpoint.