weaver.cli
¶
Module Contents¶
-
class
weaver.cli.
OperationResult
(success: Optional[bool] = None, message: Optional[str] = None, body: Optional[Union[str, weaver.typedefs.JSON]] = None, headers: Optional[weaver.typedefs.HeadersType] = None, text: Optional[str] = None, code: Optional[int] = None, **kwargs)[source]¶ Data container for any
WeaverClient
operation results.- Parameters
success – Success status of the operation.
message – Detail extracted from response content if available.
headers – Headers returned by the response for reference.
body – Content of JSON response or fallback in plain text.
text – Pre-formatted text representation of
body
.
Initialize self. See help(type(self)) for accurate signature.
-
class
weaver.cli.
WeaverClient
(url=None)[source]¶ Client that handles common HTTP requests with a Weaver or similar OGC API - Processes instance.
-
processes
[source]¶ Alias of
capabilities()
for Process listing.
-
static
_parse_result
(response: requests.Response, message: Optional[str] = None) → OperationResult[source]¶
-
static
_parse_deploy_body
(body: Optional[Union[weaver.typedefs.JSON, str]], process_id: Optional[str]) → OperationResult[source]¶
-
_parse_job_ref
(self: str, job_reference: Optional[str], url=None) → Tuple[Optional[str], Optional[str]][source]¶
-
static
_parse_auth_token
(token: Optional[str], username: Optional[str], password: Optional[str]) → weaver.typedefs.HeadersType[source]¶
-
deploy
(self: Ellipsis, process_id: Optional[str] = None, body: Optional[Union[weaver.typedefs.JSON, str]] = None, cwl: Optional[Union[weaver.typedefs.CWL, str]] = None, wps: Optional[str] = None, token: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, undeploy: bool = False, url: Optional[str] = None) → OperationResult[source]¶ Deploy a new Process with specified metadata and reference to an Application Package.
The referenced Application Package must be one of: - CWL body, local file or URL in JSON or YAML format - WPS process URL with XML response - WPS-REST process URL with JSON response - OGC API - Processes process URL with JSON response
If the reference is resolved to be a Workflow, all its underlying Process steps must be available under the same URL that this client was initialized with.
- Parameters
process_id – Desired process identifier. Can be omitted if already provided in body contents or file.
body – Literal JSON contents forming the request body, or file path/URL to YAML or JSON contents of the request body. Can be updated with other provided parameters.
cwl – Literal JSON or YAML contents, or file path/URL with contents of the CWL definition of the Application package to be inserted into the body.
wps – URL to an existing WPS process (WPS-1/2 or WPS-REST/OGC-API).
token – Authentication token for accessing private Docker registry if CWL refers to such image.
username – Username to form the authentication token to a private Docker registry.
password – Password to form the authentication token to a private Docker registry.
undeploy – Perform undeploy step as applicable prior to deployment to avoid conflict with exiting Process.
url – Instance URL if not already provided during client creation.
- Returns
results of the operation.
-
undeploy
(self: str, process_id: Optional[str], url=None) → OperationResult[source]¶ Undeploy an existing Process.
- Parameters
process_id – Identifier of the process to undeploy.
url – Instance URL if not already provided during client creation.
-
capabilities
(self: Optional[str], url=None) → OperationResult[source]¶ List all available Process on the instance.
- Parameters
url – Instance URL if not already provided during client creation.
-
describe
(self: str, process_id: Optional[str], url=None) → OperationResult[source]¶ Describe the specified Process.
- Parameters
process_id – Identifier of the process to describe.
url – Instance URL if not already provided during client creation.
-
static
_parse_inputs
(inputs: Optional[Union[str, weaver.typedefs.JSON]]) → Union[OperationResult, weaver.typedefs.JSON][source]¶
-
execute
(self: str, process_id: Optional[Union[str, weaver.typedefs.JSON]], inputs: bool = None, monitor: Optional[int] = False, timeout: Optional[int] = None, interval: Optional[str] = None, url=None) → OperationResult[source]¶ Execute a Job for the specified Process with provided inputs.
When submitting inputs with OGC API - Processes schema, top-level
inputs
key is expected. Under it, either the mapping (key-value) or listing (id,value) representation are accepted. Ifinputs
is not found, the alternative CWL will be assumed.When submitting inputs with CWL job schema, plain key-value(s) pairs are expected. All values should be provided directly under the key (including arrays), except for
File
type that must include theclass
andpath
details.- Parameters
process_id – Identifier of the process to execute.
inputs – Literal JSON or YAML contents of the inputs submitted and inserted into the execution body, using either the OGC API - Processes or CWL format, or a file path/URL referring to them.
monitor – Automatically perform Job execution monitoring until completion or timeout to obtain final results. If requested, this operation will become blocking until either the completed status or timeout is reached.
timeout – Monitoring timeout (seconds) if requested.
interval – Monitoring interval (seconds) between job status polling requests.
url – Instance URL if not already provided during client creation.
- Returns
results of the operation.
-
status
(self, job_reference, url=None)[source]¶ Obtain the status of a Job.
- Parameters
job_reference – Either the full Job status URL or only its UUID.
url – Instance URL if not already provided during client creation.
- Returns
retrieved status of the job.
-
monitor
(self: str, job_reference: Optional[int], timeout: Optional[int] = None, interval: str = None, wait_for_status: Optional[str] = STATUS_SUCCEEDED, url=None) → OperationResult[source]¶ Monitor the execution of a Job until completion.
- Parameters
job_reference – Either the full Job status URL or only its UUID.
timeout – timeout (seconds) of maximum wait time for monitoring if completion is not reached.
interval – wait interval (seconds) between polling monitor requests.
wait_for_status – monitor until the requested status is reached (default: job failed or succeeded).
url – Instance URL if not already provided during client creation.
- Returns
result of the successful or failed job, or timeout of monitoring process.
-
results
(self: str, job_reference: Optional[str], out_dir: bool = None, download: Optional[str] = False, url=None) → OperationResult[source]¶ Obtain the results of a successful Job execution.
- Parameters
job_reference – Either the full Job status URL or only its UUID.
out_dir – Output directory where to store downloaded files if requested (default: CURDIR/JobID/<outputs>).
download – Download any file reference found within results (CAUTION: could transfer lots of data!).
url – Instance URL if not already provided during client creation.
- Returns
Result details and local paths if downloaded.
-
dismiss
(self, job_reference, url=None)[source]¶ Dismiss pending or running Job, or clear result artifacts from a completed Job.
- Parameters
job_reference – Either the full Job status URL or only its UUID.
url – Instance URL if not already provided during client creation.
- Returns
Obtained result from the operation.
-
-
weaver.cli.
setup_logger_from_options
(logger: logging.Logger, args: argparse.Namespace) → None[source]¶ Uses argument parser options to setup logging level from specified flags.
Setup both the specific CLI logger that is provided and the top-level package logger.
-
weaver.cli.
make_logging_options
(parser: argparse.ArgumentParser) → None[source]¶ Defines argument parser options for logging operations.
-
class
weaver.cli.
InputsFormatter
(prog, indent_increment=2, max_help_position=24, width=None)[source]¶ Formatter for generating usage messages and argument help strings.
Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail.
-
weaver.cli.
make_parser
() → argparse.ArgumentParser[source]¶ Generate the CLI parser.