weaver.datatype
¶
Module Contents¶
-
class
weaver.datatype.
DictBase
[source]¶ Dictionary with extended attributes auto-
getter
/setter
for convenience.Explicitly overridden
getter
/setter
attributes are called instead ofdict
-keyget
/set
-item to ensure corresponding checks and/or value adjustments are executed before applying it to the sub-dict
.Initialize self. See help(type(self)) for accurate signature.
-
class
weaver.datatype.
AutoBase
[source]¶ Base that automatically converts literal class members to properties also accessible by dictionary keys.
class Data(AutoBase): field = 1 other = None d = Data() d.other # returns None d.other = 2 # other is modified d.other # returns 2 dict(d) # returns {'field': 1, 'other': 2} d.field # returns 1 d["field"] # also 1 !
Initialize self. See help(type(self)) for accurate signature.
-
class
weaver.datatype.
Base
[source]¶ Dictionary with extended attributes auto-
getter
/setter
for convenience.Explicitly overridden
getter
/setter
attributes are called instead ofdict
-keyget
/set
-item to ensure corresponding checks and/or value adjustments are executed before applying it to the sub-dict
.Initialize self. See help(type(self)) for accurate signature.
-
abstract
json
(self) → weaver.typedefs.JSON[source]¶ Obtain the JSON data representation for response body.
Note
This method implementation should validate the JSON schema against the API definition whenever applicable to ensure integrity between the represented data type and the expected API response.
-
abstract
-
class
weaver.datatype.
Service
(*args, **kwargs)[source]¶ Dictionary that contains OWS services.
It always has
url
key.Initialize self. See help(type(self)) for accurate signature.
-
json
(self) → weaver.typedefs.JSON[source]¶ Obtain the JSON data representation for response body.
Note
This method implementation should validate the JSON schema against the API definition whenever applicable to ensure integrity between the represented data type and the expected API response.
-
params
(self) → AnyParams[source]¶ Obtain the internal data representation for storage.
Note
This method implementation should provide a JSON-serializable definition of all fields representing the object to store.
-
wps
(self: weaver.typedefs.AnySettingsContainer, container: Any = None, **kwargs) → owslib.wps.WebProcessingService[source]¶ Obtain the remote WPS service definition and metadata.
Stores the reference locally to avoid re-fetching it needlessly for future reference.
-
links
(self: weaver.typedefs.AnySettingsContainer, container: bool, fetch: Optional[str] = True, self_link=None) → List[weaver.typedefs.JSON][source]¶ Obtains the links relevant to the service Provider.
- Parameters
container -- object that helps retrieve instance details, namely the host URL.
fetch -- whether to attempt retrieving more precise details from the remote provider.
self_link -- name of a section that represents the current link that will be returned.
-
metadata
(self: weaver.typedefs.AnySettingsContainer, container) → List[weaver.typedefs.JSON][source]¶ Obtains the metadata relevant to the service provider.
-
keywords
(self: weaver.typedefs.AnySettingsContainer, container=None) → List[str][source]¶ Obtains the keywords relevant to the service provider.
-
summary
(self: weaver.typedefs.AnySettingsContainer, container: bool, fetch: bool = True, ignore=False) → Optional[weaver.typedefs.JSON][source]¶ Obtain the summary information from the provider service.
When metadata fetching is disabled, the generated summary will contain only information available locally.
- Parameters
container -- employed to retrieve application settings.
fetch -- indicates whether metadata should be fetched from remote.
ignore -- indicates if failing metadata retrieval/parsing should be silently discarded or raised.
- Returns
generated summary information.
-
processes
(self: weaver.typedefs.AnySettingsContainer, container: bool, ignore=False) → Optional[List[Process]][source]¶ Obtains a list of remote service processes in a compatible
weaver.datatype.Process
format.Note
Remote processes won't be stored to the local process storage.
- Parameters
container -- Employed to retrieve application settings.
ignore -- Indicates if failing service retrieval/parsing should be silently discarded or raised.
- Raises
ServiceParsingError -- If parsing failed and was NOT requested to be ignored.
- Returns
If parsing was successful, list of converted remote service processes. If parsing failed and was requested to be ignored, returns
None
to distinguish from empty process list.
-
-
class
weaver.datatype.
Job
(*args, **kwargs)[source]¶ Dictionary that contains OWS service jobs.
It always has
id
andtask_id
keys.Initialize self. See help(type(self)) for accurate signature.
-
_get_log_msg
(self: Optional[str], msg: Optional[str] = None, status: Optional[weaver.typedefs.Number] = None, progress=None) → str[source]¶
-
save_log
(self: Ellipsis, errors: Optional[Union[str, Exception, owslib.wps.WPSException, List[owslib.wps.WPSException]]] = None, logger: Optional[logging.Logger] = None, message: Optional[str] = None, level: int = INFO, status: Optional[str] = None, progress: Optional[weaver.typedefs.Number] = None) → None[source]¶ Logs the specified error and/or message, and adds the log entry to the complete job log.
For each new log entry, additional
Job
properties are added according toJob._get_log_msg()
and the format defined byget_job_log_msg()
.- Parameters
errors -- An error message or a list of WPS exceptions from which to log and save generated message stack.
logger -- An additional
Logger
for which to propagate logged messages on top saving them to the job.message -- Explicit string to be logged, otherwise use the current
Job.status_message
is used.level -- Logging level to apply to the logged
message
. This parameter is ignored iferrors
are logged.status -- Override status applied in the logged message entry, but does not set it to the job object. Uses the current
Job.status
value if not specified. Must be one ofWeaver.status
values.progress -- Override progress applied in the logged message entry, but does not set it to the job object. Uses the current
Job.progress
value if not specified.
Note
The job object is updated with the log but still requires to be pushed to database to actually persist it.
-
property
task_id
(self) → Optional[weaver.typedefs.AnyUUID][source]¶ Reference Task UUID attributed by the
Celery
worker that monitors and executes this job.
-
property
wps_id
(self) → Optional[uuid.UUID][source]¶ Reference WPS Request/Response UUID attributed by the executed
PyWPS
process.This UUID matches the status-location, log and output directory of the WPS process. This parameter is only available when the process is executed on this local instance.
See also
-
property
service
(self) → Optional[str][source]¶ Service identifier of the corresponding remote process.
See also
-
property
process
(self) → Optional[str][source]¶ Process identifier of the corresponding remote process.
See also
-
property
type
(self) → str[source]¶ Obtain the type of the element associated to the creation of this job.
See also
Defined in https://docs.ogc.org/DRAFTS/18-062.html#_response_6 (within
StatusInfo
schema).Queried with https://docs.ogc.org/DRAFTS/18-062.html#_parameter_type
-
property
created
(self) → datetime.datetime[source]¶
-
property
started
(self) → Optional[datetime.datetime][source]¶
-
property
finished
(self) → Optional[datetime.datetime][source]¶
-
property
updated
(self) → datetime.datetime[source]¶
-
property
duration
(self) → Optional[datetime.timedelta][source]¶
-
property
request
(self) → Optional[str][source]¶ XML request for WPS execution submission as string (binary).
-
property
response
(self) → Optional[str][source]¶ XML status response from WPS execution submission as string (binary).
-
links
(self: Optional[weaver.typedefs.AnySettingsContainer], container: Optional[str] = None, self_link=None) → List[weaver.typedefs.JSON][source]¶ Obtains the JSON links section of the response body for a Job.
If
self_link
is provided (e.g.: "outputs") the link for that corresponding item will also be added as self entry to the links. It must be a recognized job link field.- Parameters
container -- object that helps retrieve instance details, namely the host URL.
self_link -- name of a section that represents the current link that will be returned.
-
json
(self: Optional[weaver.typedefs.AnySettingsContainer], container: Optional[str] = None, self_link=None) → weaver.typedefs.JSON[source]¶ Obtains the JSON data representation for response body.
Note
Settings are required to update API shortcut URLs to job additional information. Without them, paths will not include the API host, which will not resolve to full URI.
-
-
class
weaver.datatype.
AuthenticationTypes
[source]¶ Generic enumeration.
Derive from this class to define new enumerations.
-
class
weaver.datatype.
Authentication
(auth_type: str, auth_scheme: str, auth_token: str, auth_link: Any, **kwargs)[source]¶ Authentication details to store details required for process operations.
Initialize self. See help(type(self)) for accurate signature.
-
property
type
(self) → AuthenticationTypes[source]¶
-
json
(self)[source]¶ Obtain the JSON data representation for response body.
Note
This method implementation should validate the JSON schema against the API definition whenever applicable to ensure integrity between the represented data type and the expected API response.
-
params
(self) → AnyParams[source]¶ Obtain the internal data representation for storage.
Note
This method implementation should provide a JSON-serializable definition of all fields representing the object to store.
-
classmethod
from_params
(cls: Any, **params) → AnyAuthentication[source]¶ Obtains the specialized
Authentication
using loaded parameters fromparams()
.
-
property
-
class
weaver.datatype.
DockerAuthentication
(auth_scheme: str, auth_token: str, docker_image_link: Any, **kwargs)[source]¶ Authentication associated to a Docker image to retrieve from a private registry given by the reference link.
See also
Initialize self. See help(type(self)) for accurate signature.
-
property
credentials
(self) → weaver.typedefs.JSON[source]¶ Generates the credentials to submit the login operation based on the authentication token and scheme.
-
property
image
(self) → str[source]¶ Obtains the image portion of the reference without repository prefix.
-
property
registry
(self) → str[source]¶ Obtains the registry entry that must used for
docker login <registry>
.
-
property
docker
(self) → str[source]¶ Obtains the full reference required when doing Docker operations such as
docker pull <reference>
.
-
property
repository
(self) → str[source]¶ Obtains the full Docker repository reference without any tag.
-
params
(self) → AnyParams[source]¶ Obtain the internal data representation for storage.
Note
This method implementation should provide a JSON-serializable definition of all fields representing the object to store.
-
classmethod
from_params
(cls: Any, **params) → DockerAuthentication[source]¶ Generate class with parameters directly skipping validation/parsing from initialization.
Warning
This should be reserved for self-manipulation only when resolving
Authentication
type.
-
property
-
class
weaver.datatype.
Process
(*args, **kwargs)[source]¶ Dictionary that contains a process definition for db storage.
It always has
identifier
(orid
alias) and apackage
definition. Parameters can be accessed by key or attribute, and appropriate validators or default values will be applied.Initialize self. See help(type(self)) for accurate signature.
-
property
inputs
(self) → Optional[List[Dict[str, weaver.typedefs.JSON]]][source]¶ Inputs of the process following backward-compatible conversion of stored parameters.
- According to OGC-API,
maxOccurs
andminOccurs
representations should be: maxOccurs
:int
or"unbounded"
minOccurs
:int
- And,
mediaType
should be in description as: mediaType
:string
Note
Because of pre-registered/deployed/retrieved remote processes, inputs are formatted in-line to respect valid OGC-API schema representation and apply any required correction transparently.
- According to OGC-API,
-
property
outputs
(self) → Optional[List[Dict[str, weaver.typedefs.JSON]]][source]¶ Outputs of the process following backward-compatible conversion of stored parameters.
- According to OGC-API,
mediaType
should be in description as: mediaType
:string
Note
Because of pre-registered/deployed/retrieved remote processes, inputs are formatted in-line to respect valid OGC-API schema representation and apply any required correction transparently.
- According to OGC-API,
-
property
type
(self) → str[source]¶ Type of process amongst
weaver.processes.types
definitions.
-
static
_recursive_replace
(pkg: weaver.typedefs.JSON, index_from: int, index_to: int) → weaver.typedefs.JSON[source]¶
-
property
auth
(self) → Optional[AnyAuthentication][source]¶ Authentication token required for operations with the process.
-
params
(self) → AnyParams[source]¶ Obtain the internal data representation for storage.
Note
This method implementation should provide a JSON-serializable definition of all fields representing the object to store.
-
property
params_wps
(self) → AnyParams[source]¶ Values applicable to create an instance of
pywps.app.Process
.
-
dict
(self)[source]¶ Generate a dictionary representation of the object, but with inplace resolution of attributes as applicable.
-
json
(self) → weaver.typedefs.JSON[source]¶ Obtains the JSON serializable complete representation of the process.
-
links
(self: Optional[weaver.typedefs.AnySettingsContainer], container=None) → weaver.typedefs.JSON[source]¶ Obtains the JSON links section of many response body for the Process.
- Parameters
container -- object that helps retrieve instance details, namely the host URL.
-
offering
(self: str, schema=PROCESS_SCHEMA_OGC) → weaver.typedefs.JSON[source]¶ Obtains the JSON serializable offering/description representation of the process.
- Parameters
schema -- One of values defined by
sd.ProcessDescriptionSchemaQuery
to select which process description representation to generate (see each schema for details).
Note
Property name
offering
is employed to differentiate from the string processdescription
field. The result of this JSON representation is still theProcessDescription
schema.
-
summary
(self) → weaver.typedefs.JSON[source]¶ Obtains the JSON serializable summary representation of the process.
-
static
from_wps
(wps_process: pywps.Process, **extra_params: Any) → Process[source]¶ Converts a
pywps
Process into aweaver.datatype.Process
using provided parameters.
-
static
from_ows
(process: owslib.wps.Process, service: Service, container: weaver.typedefs.AnySettingsContainer, **kwargs: Any) → Process[source]¶ Converts a
owslib.wps
Process to local storageweaver.datatype.Process
.
-
property
service
(self) → Optional[str][source]¶ Name of the parent service provider under which this process resides.
See also
-
property
-
class
weaver.datatype.
Quote
(*args, **kwargs)[source]¶ Dictionary that contains quote information.
It always has
id
andprocess
keys.Initialize self. See help(type(self)) for accurate signature.
-
class
weaver.datatype.
Bill
(*args, **kwargs)[source]¶ Dictionary that contains bill information.
It always has
id
,user
,quote
andjob
keys.Initialize self. See help(type(self)) for accurate signature.