openimis-be-workflow_py

The OpenIMIS Backend Workflow Reference Module is a crucial component of the OpenIMIS system. This module is dedicated to managing workflows and integrating with various workflow systems. It provides services and functionalities to register workflow systems, query available workflows, and execute workflows. The Workflow Reference Module is designed to be deployed as a module of openimis-be_py, the OpenIMIS backend application.

This documentation aims to provide a comprehensive guide on how to utilize and interact with the Workflow Reference Module effectively.

Services

The Workflow Reference Module provides the following service:

  • WorkflowService: Offers methods to register workflow systems, query available workflows, and execute workflows.

Developers can interact with this service to perform various operations related to workflows.

Registering Workflow Systems

The Workflow Service can be extended with custom adaptors to integrate with new workflow systems. Any adaptor must extend workflow.systems.base.WorkflowAdaptor and return triggers as implementations of workflow.systems.base.WorkflowHandler.

Example:

# Example of extending WorkflowAdaptor class CustomWorkflowAdaptor(WorkflowAdaptor): def get_triggers(self): # Implement logic to retrieve triggers from the custom workflow system return [CustomWorkflowHandler1(), CustomWorkflowHandler2(), ...] # Register the custom workflow adaptor WorkflowService.register_system_adaptor(CustomWorkflowAdaptor)

Querying Workflows

Querying available workflows can be done using the WorkflowService.get_workflows service. All registered workflow systems must implement filtering workflows by group and name.

Example:

# Querying available workflows with group and name filter workflows_result = WorkflowService.get_workflows(group='default', name='example') if workflows_result['success']: workflow_handlers = workflows_result['data']['workflows']

Executing Workflows

Workflow handlers are self-contained triggers for a specific workflow in a given system. The WorkflowHandler.run method allows performing a workflow run with a given payload. Depending on the system, workflow runs can be synchronous and return the result of the workflow or asynchronous and return necessary information to check the workflow status in a given workflow system.

Example:

# Executing a workflow with a payload payload = { ... } result = handler.run(payload)

Did you encounter a problem or do you have a suggestion?

Please contact our Service Desk



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/