flowserv.service.local module

Helper classes method to create instances of the API components. The local API operates directly on the flowserv database (as opposed to the remote API that interacts with a local API via a RESTfule API) and provides the ability to execute workflows on the local machine using an associated workflow engine.

All API components use the same underlying database connection. The connection object is under the control of of a context manager to ensure that the connection is closed properly after every API request has been handled.

class flowserv.service.local.LocalAPIFactory(env: Optional[Dict] = None, db: Optional[flowserv.model.database.DB] = None, engine: Optional[flowserv.controller.base.WorkflowController] = None, user_id: Optional[str] = None)

Bases: flowserv.service.api.APIFactory

Factory for context manager that create local API instances. Provides a wrapper around the database and the workflow engine.

cancel_run(run_id: str)

Request to cancel execution of the given run.

Parameters

run_id (string) – Unique run identifier

Raises

flowserv.error.UnknownRunError

exec_workflow(run: flowserv.model.base.RunObject, template: flowserv.model.template.base.WorkflowTemplate, arguments: Dict, staticfs: flowserv.volume.base.StorageVolume, config: Optional[Dict] = None) Tuple[flowserv.model.workflow.state.WorkflowState, flowserv.volume.base.StorageVolume]

Initiate the execution of a given workflow template for a set of argument values. Returns the state of the workflow and the path to the directory that contains run result files for successful runs.

The client provides a unique identifier for the workflow run that is being used to retrieve the workflow state in future calls.

If the state of the run handle is not pending, an error is raised.

Parameters
  • run (flowserv.model.base.RunObject) – Handle for the run that is being executed.

  • template (flowserv.model.template.base.WorkflowTemplate) – Workflow template containing the parameterized specification and the parameter declarations.

  • arguments (dict) – Dictionary of argument values for parameters in the template.

  • staticfs (flowserv.volume.base.StorageVolume) – Storage volume that contains the static files from the workflow template.

  • config (dict, default=None) – Optional implementation-specific configuration settings that can be used to overwrite settings that were initialized at object creation.

Return type

flowserv.model.workflow.state.WorkflowState, flowserv.volume.base.StorageVolume

class flowserv.service.local.SessionManager(env: Dict, db: flowserv.model.database.DB, engine: flowserv.controller.base.WorkflowController, fs: flowserv.volume.base.StorageVolume, user_id: str, access_token: str)

Bases: object

Context manager that creates a local API and controls the database session that is used by all the API components.

flowserv.service.local.init_backend(api: flowserv.service.api.APIFactory) flowserv.controller.base.WorkflowController

Create an instance of the workflow engine based on the given configuration settings. The workflow engine receives a reference to the API factory for callback operations that modify the global database state.

Parameters
  • env (dict, default=None) – Dictionary that provides access to configuration parameter values.

  • api (flowserv.service.api.APIFactory) – Reference to tha API factory for callbacks that modify the global database state.

Return type

flowserv.controller.base.WorkflowController

flowserv.service.local.init_db(env: Dict) flowserv.model.database.DB

Create an instance of the database object based on the given configuration settings. Sets the respective variables to the default value if not set.

Parameters

env (dict, default=None) – Dictionary that provides access to configuration parameter values.

Return type

flowserv.model.database.DB