weaver.execute
Module Contents
- class weaver.execute.ExecuteMode[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.
- class weaver.execute.ExecuteControlOption[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.- classmethod values() List[AnyExecuteControlOption][source]
Return default control options in specific order according to preferred modes for execution by Weaver.
- classmethod from_mode(mode: AnyExecuteMode | None) ExecuteControlOption | None[source]
- class weaver.execute.ExecuteReturnPreference[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.
- class weaver.execute.ExecuteResponse[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.
- class weaver.execute.ExecuteTransmissionMode[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.
- class weaver.execute.ExecuteCollectionFormat[source]
Constants container that provides similar functionalities to
ExtendedEnumwithout explicit Enum membership.
- weaver.execute.parse_prefer_header_return(headers: weaver.typedefs.AnyHeadersContainer) AnyExecuteReturnPreference | None[source]
Get the return preference if specified.
- weaver.execute.parse_prefer_header_execute_mode(header_container: weaver.typedefs.AnyHeadersContainer, supported_modes: List[AnyExecuteControlOption] | None = None, wait_max: int = 10, return_auto: bool = False) Tuple[AnyExecuteMode, int | None, weaver.typedefs.HeadersType][source]
Obtain execution preference if provided in request headers.
See also
OGC API - Processes: Core, Execution mode < https://docs.ogc.org/is/18-062r2/18-062r2.html#sc_execution_mode>`_. This defines all conditions how to handle
Preferagainst applicable Process description.RFC 7240 Section 4.1 HTTP Prefer header
respond-async
See also
If
Preferformat is valid, but server decides it cannot be respected, it can be transparently ignored (RFC 7240 Section 2). The server must respond withPreference-Appliedindicating preserved preferences it decided to respect.- Parameters:
header_container – Request headers to retrieve preference, if any available.
supported_modes – Execute modes that are permitted for the operation that received the
Preferheader. Resolved mode will respect this constraint following specification requirements of OGC API - Processes.wait_max – Maximum wait time enforced by the server. If requested wait time is greater,
waitpreference will not be applied and will fall back to asynchronous response.return_auto – If the resolution ends up being an “auto” selection, the auto-resolved mode, wait-time, etc. are returned by default. Using this option, the “auto” mode will be explicitly returned instead, allowing a mixture of execution mode to be “auto” handled at another time. This is mostly for reporting purposes.
- Returns:
Tuple of resolved execution mode, wait time if specified, and header of applied preferences if possible. Maximum wait time indicates duration until synchronous response should fall back to asynchronous response.
- Raises:
HTTPBadRequest – If contents of
Preferare not valid.
- weaver.execute.rebuild_prefer_header(job: weaver.datatype.Job) str | None[source]
Rebuilds the expected
Preferheader value from Job parameters.
- weaver.execute.update_preference_applied_return_header(job: weaver.datatype.Job, request_headers: weaver.typedefs.AnyHeadersContainer | None, response_headers: weaver.typedefs.PreservedHeadersType | None) weaver.typedefs.PreservedHeadersType[source]
Updates the
Preference-Appliedheader according to available information.- Parameters:
job – Job where the desired return preference has be resolved.
request_headers – Original request headers, to look for any
Prefer: return.response_headers – Already generated response headers, to extend
Preference-Appliedheader as needed.
- Returns:
Updated response headers with any resolved return preference.
- weaver.execute.resolve_execution_parameters(job_control_options: List[ExecuteControlOption], execute_headers: weaver.typedefs.AnyHeadersContainer, execute_mode: AnyExecuteMode | None = None, execute_return: AnyExecuteReturnPreference | None = None, execute_max_wait: int | None = None) Tuple[AnyExecuteMode, AnyExecuteResponse, weaver.typedefs.AnyHeadersContainer][source]
Resolve execution parameters from provided Job control options and Process execution headers.
The execution mode override, if provided, takes precedence over any header preference. If the Process only supports a single execution mode, it is enforced regardless of any preference. If that option mismatches the override, an exception is raised.
If no override is provided, or no preference is specified in headers, the asynchronous mode will be employed in case of multiple supported modes.
See also
Execution Body, Execution Mode and Execution Results provide combination matrices and details on how execution parameters interact and affect the execution and response strategies.
Note
Returned parameters include multiple “equivalent” or “redundant” variants to handle both OGC API - Processes
v1andv2, and various combinations the servers could implement.- Parameters:
job_control_options – The allowed execution methods that the Process supports.
execute_headers – Any preestablished headers that could hint a preferred execution mode.
execute_mode – Explicit execution mode to enforce, if any.
execute_return – Explicit return preference to enforce, if any.
execute_max_wait – Maximum wait time for synchronous execution, as applicable.
- Returns:
Resolved execution mode and corresponding headers to apply.
- Raises:
ProcessInvalidParameter – If the requested execution mode does not respect the supported ones.