weaver.processes.utils

Module Contents

weaver.processes.utils.LOGGER[source]
weaver.processes.utils.get_process(process_id: Optional[str] = None, request: Optional[pyramid.request.Request] = None, settings: Optional[weaver.typedefs.SettingsType] = None, store: Optional[weaver.store.base.StoreProcesses] = None)weaver.datatype.Process[source]

Obtain the specified process and validate information, returning appropriate HTTP error if invalid.

Process identifier must be provided from either the request path definition or literal ID. Database must be retrievable from either the request, underlying settings, or direct store reference.

Different parameter combinations are intended to be used as needed or more appropriate, such that redundant operations can be reduced where some objects are already fetched from previous operations.

weaver.processes.utils.get_job_submission_response(body: weaver.typedefs.JSON)pyramid.httpexceptions.HTTPCreated[source]

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

weaver.processes.utils.map_progress(progress: weaver.typedefs.Number, range_min: weaver.typedefs.Number, range_max: weaver.typedefs.Number)weaver.typedefs.Number[source]

Calculates the relative progression of the percentage process within min/max values.

weaver.processes.utils._check_deploy(payload)[source]

Validate minimum deploy payload field requirements with exception handling.

weaver.processes.utils._validate_deploy_process_info(process_info, reference, package, settings)[source]

Obtain the process definition from deploy payload with exception handling.

weaver.processes.utils.deploy_process_from_payload(payload: weaver.typedefs.JSON, container: weaver.typedefs.AnyContainer, overwrite: bool = False)pyramid.httpexceptions.HTTPException[source]

Deploy the process after resolution of all references and validation of the parameters from payload definition.

Adds a weaver.datatype.Process instance to storage using the provided JSON payload matching weaver.wps_restapi.swagger_definitions.ProcessDescription.

Parameters
  • payload – JSON payload that was specified during the process deployment request.

  • container – container to retrieve application settings.

  • overwrite – whether to allow override of an existing process definition if conflict occurs.

Returns

HTTPOk if the process registration was successful.

Raises

HTTPException – for any invalid process deployment step.

weaver.processes.utils.parse_wps_process_config(config_entry: Union[weaver.typedefs.JSON, str])Tuple[str, str, List[str], bool][source]

Parses the available WPS provider or process entry to retrieve its relevant information.

Returns

WPS provider name, WPS service URL, and list of process identifier(s).

Raises

ValueError – if the entry cannot be parsed correctly.

weaver.processes.utils.register_wps_processes_static(service_url: str, service_name: str, service_visibility: bool, service_processes: List[str], container: weaver.typedefs.AnySettingsContainer)None[source]

Register WPS-1 Process under a service Provider as static references.

For a given WPS provider endpoint, either iterates over all available processes under it to register them one by one, or limit itself only to those of the reduced set specified by service_processes.

The registered WPS-1 processes generate a static reference, meaning that metadata of each process as well as any other modifications to the real remote reference will not be tracked, including validation of even their actual existence, or modifications to inputs/outputs. The Application Package will only point to it assuming it remains valid.

Each of the deployed processes using static reference will be accessible directly under Weaver endpoints:

/processes/<service-name>_<process-id>

The service is NOT deployed as Provider since the processes are registered directly.

Parameters
  • service_url – WPS-1 service location (where GetCapabilities and DescribeProcess requests can be made).

  • service_name – Identifier to employ for generating the full process identifier.

  • service_visibility – Visibility flag of the provider.

  • service_processes – process IDs under the service to be registered, or all if empty.

  • container – settings to retrieve required configuration settings.

weaver.processes.utils.register_wps_processes_dynamic(service_name: str, service_url: str, service_visibility: bool, container: weaver.typedefs.AnySettingsContainer)None[source]

Register a WPS service provider such that processes under it are dynamically accessible on demand.

The registered WPS-1 provider generates a dynamic reference to processes under it. Only the Provider reference itself is actually registered. No Process are directly registered following this operation.

When information about the offered processes, descriptions of those processes or their execution are requested, Weaver will query the referenced Provider for details and convert the corresponding Process dynamically. This means that latest metadata of the Process, and any modification to it on the remote service will be immediately reflected on Weaver without any need to re-deploy processes.

Each of the deployed processes using dynamic reference will be accessible under Weaver endpoints:

/providers/<service-name>/processes/<process-id>

The processes are NOT deployed locally since the processes are retrieved from the Provider itself.

Parameters
  • service_url – WPS-1 service location (where GetCapabilities and DescribeProcess requests can be made).

  • service_name – Identifier to employ for registering the provider identifier.

  • service_visibility – Visibility flag of the provider.

  • container – settings to retrieve required configuration settings.

weaver.processes.utils.register_wps_processes_from_config(wps_processes_file_path: Optional[weaver.typedefs.FileSystemPathType], container: weaver.typedefs.AnySettingsContainer)None[source]

Registers remote WPS providers and/or processes as specified from the configuration file.

Loads a wps_processes.yml file and registers WPS-1 providers processes to the current Weaver instance as equivalent WPS-2 processes.

References listed under processes are registered. When the reference is a service (provider), registration of each WPS process is done individually for each of the specified providers with ID [service]_[process] per listed process by GetCapabilities.

New in version 1.14.0: When references are specified using providers section instead of processes, the registration only saves the remote WPS provider endpoint to dynamically populate WPS processes on demand.

See also

  • weaver.wps_processes.yml.example for additional file format details