weaver.wps_restapi.jobs.utils

Module Contents

weaver.wps_restapi.jobs.utils.LOGGER[source]
weaver.wps_restapi.jobs.utils.get_job(request: weaver.typedefs.PyramidRequest) weaver.datatype.Job[source]

Obtain a Job from request parameters.

Changed in version 4.20: When looking for Job that refers to a local Process, allow implicit resolution of the unspecified version portion to automatically resolve the identifier. Consider that validation of the expected Process for this Job is “good enough”, since the specific ID is not actually required to obtain the Job (could be queried by ID only on the /jobs/{jobId} endpoint. If the version is provided though (either query parameter or tagged representation), the validation will ensure that it matches explicitly.

Parameters

request – Request with path and query parameters to retrieve the desired job.

Returns

Job information if found.

Raises

HTTPNotFound – with JSON body details on missing/non-matching job, process, provider IDs.

Obtains a list of all relevant links for the corresponding job listing defined by query parameter filters.

Raises

IndexError – if the paging values are out of bounds compared to available total Job matching search.

weaver.wps_restapi.jobs.utils.get_schema_query(schema: Optional[weaver.wps_restapi.constants.JobInputsOutputsSchemaType], strict: bool = True) Optional[weaver.wps_restapi.constants.JobInputsOutputsSchemaType][source]

Convert a result definition as value into the corresponding reference for output transmission.

See also

RFC 8288: HTTP Link header specification.

weaver.wps_restapi.jobs.utils.get_results(job: Ellipsis, container: weaver.typedefs.AnySettingsContainer, value_key: Optional[str] = None, schema: weaver.wps_restapi.constants.JobInputsOutputsSchemaType = JobInputsOutputsSchema.OLD, link_references: bool = False) Tuple[weaver.typedefs.ExecutionResults, weaver.typedefs.HeadersTupleType][source]

Obtains the job results with extended full WPS output URL as applicable and according to configuration settings.

Parameters
  • job – job from which to retrieve results.

  • container – any container giving access to instance settings (to resolve reference output location).

  • value_key – If not specified, the returned values will have the appropriate data/href key according to the content. Otherwise, all values will have the specified key.

  • schema – Selects which schema to employ for representing the output results (listing or mapping).

  • link_references – If enabled, an output that was requested by reference instead of value will be returned as Link reference.

Returns

Tuple with:
  • List or mapping of all outputs each with minimally an ID and value under the requested key.

  • List of Link headers for reference outputs when requested. Empty otherwise.

weaver.wps_restapi.jobs.utils.get_job_results_response(job: weaver.datatype.Job, container: weaver.typedefs.AnySettingsContainer, headers: Optional[weaver.typedefs.AnyHeadersContainer] = None) weaver.typedefs.AnyResponseType[source]

Generates the OGC compliant Job results response according to submitted execution parameters.

Parameters that impact the format of the response are:
  • Amount of outputs to be returned.

  • Parameter response: raw|document

  • Parameter transmissionMode: value|reference per output if response: raw.

Parameters
  • job – Job for which to generate the results response.

  • container – Application settings.

  • headers – Additional headers to provide in the response.

weaver.wps_restapi.jobs.utils.get_job_submission_response(body: weaver.typedefs.JSON, headers: weaver.typedefs.AnyHeadersContainer, error: bool = False) Union[pyramid.httpexceptions.HTTPOk, pyramid.httpexceptions.HTTPCreated][source]

Generates the successful response from contents returned by Job submission process.

If Job already finished processing within requested Prefer: wait=X seconds delay (and if allowed by the Process jobControlOptions), return the successful status immediately instead of created status.

Otherwise, return the status monitoring location of the created Job to be monitored asynchronously.

weaver.wps_restapi.jobs.utils.validate_service_process(request: weaver.typedefs.PyramidRequest) Tuple[Optional[str], Optional[str]][source]

Verifies that service or process specified by path or query will raise the appropriate error if applicable.

weaver.wps_restapi.jobs.utils.raise_job_bad_status(job: weaver.datatype.Job, container: Optional[weaver.typedefs.AnySettingsContainer] = None) None[source]

Raise the appropriate message for Job not ready or unable to retrieve output results due to status.

weaver.wps_restapi.jobs.utils.raise_job_dismissed(job: weaver.datatype.Job, container: Optional[weaver.typedefs.AnySettingsContainer] = None) None[source]

Raise the appropriate messages for dismissed Job status.

weaver.wps_restapi.jobs.utils.dismiss_job_task(job: weaver.datatype.Job, container: weaver.typedefs.AnySettingsContainer) weaver.datatype.Job[source]

Cancels any pending or running Celery task and removes completed job artifacts.

Note

The Job object itself is not deleted, only its artifacts. Therefore, its inputs, outputs, logs, exceptions, etc. are still available in the database, but corresponding files that would be exposed by weaver.wps_output configurations are removed.

Parameters
  • job – Job to cancel or cleanup.

  • container – Application settings.

Returns

Updated and dismissed job.