Gladier Base Client
- class gladier.client.GladierBaseClient(authorizers: Optional[Mapping[str, Union[AccessTokenAuthorizer, RefreshTokenAuthorizer]]] = None, auto_login: bool = True, auto_registration: bool = True, login_manager: Optional[BaseLoginManager] = None, flows_manager: Optional[FlowsManager] = None)
Bases:
object
The Gladier Client ties together commonly used funcx functions and basic flows with auto-registration tools to make complex tasks easy to automate.
This class is intended to be subclassed as follows:
@generate_flow_definition class MyGladierClient(GladierBaseClient): gladier_tools = [MyTool]
And used like the following:
my_gc = MyGladierClient() flow = my_gc.run_flow(flow_input={"flow_input": {"my_field": "foo"}}) run_id = flow["run_id"] my_gc.progress(run_id) pprint(tar_and_transfer.get_status(run_id))
The following class variables can be set on clients to change their behavior when deploying and running flows.
- glaider_tools (default: [])
A list of Gladier Tools to build a working flow_defitinion. Each tool’s minimum input must be satisfied prior to running the flow. Can be used with the @generate_flow_definition decorator to automatically chain together flow definitions present on each tool in linear order.
- flow_definition (default: {})
An explicit flow definition to use for this client. Cannot be used with @generate_flow_definition
- secret_config_filename (default:
~/.gladier-secrets.cfg
) Storage are for Globus Tokens and general storage
- secret_config_filename (default:
- app_name (default: ‘Gladier Client’)
The app name used during a login flow
- client_id
The Globus Client ID used for native logins
- globus_group (default: None)
A Globus Group to be applied to all flow/run permissions. Group will automatically be added to flow_viewers, flow_starters, flow_administrators, run_managers, run_monitors
- subscription_id (default: None)
The subscription id associated with this flow
- alias_class (default: gladier.utils.tool_alias.StateSuffixVariablePrefix)
The default class used to for applying aliases to Tools
Default options are intended for CLI usage and maximum user convenience.
- Parameters:
auto_registration – Automatically register functions or flows if they are not previously registered or obsolete.
login_manager – Class defining login behavior. Defaults to AutoLoginManager, and will auto-login when additional scopes are needed.
flows_manager – A flows manager class with customized behavior. Attrs like group and login_manager will automatically be set if None
- Raises:
gladier.exc.AuthException – if authorizers given are insufficient
- login()
Call
login()
on the configured login manager. Attepmts to prepare the user to run flows, but may require being called twice if a flow is not yet deployed. Automatically called internally byrun_flow()
if required.
- logout()
Call
logout()
on the login manager, to revoke saved tokens and deactivate the current flow. The flow_id and function ids/checksums are unaffected, and can be re-used after another invocation oflogin()
.
- get_input() dict
Get funcx function ids, funcx endpoints, and each tool’s default input. Default input may not be enough to run the flow. For example if a tool does processing on a local filesystem, the file will always need to be provided by the user when calling run_flow().
Defaults rely on GladierBaseTool.flow_input defined separately for each tool.
- Returns:
input for a flow wrapped in an ‘input’ dict. For example: {‘input’: {‘foo’: ‘bar’}}
- get_status(action_id: str)
Get the current status of the automate flow. Attempts to do additional work on funcx functions to deserialize any exception output.
- Parameters:
action_id – The globus action UUID used for this flow. The Automate flow id is always the flow_id configured for this tool.
- Raises:
Globus Automate exceptions from self.flows_client.flow_action_status
- Returns:
a Globus Automate status object (with varying state structures)
- progress(action_id, callback=None)
Continuously call self.get_status() until the flow completes. Each status response is used as a parameter to the provided callback, by default will use the builtin callback to print the current state to stdout.
- Parameters:
action_id – The action id for a running flow. The flow is automatically pulled based on the current tool’s flow_definition.
callback – The function to call with the result from self.get_status. Must take a single parameter: mycallback(self.get_status())