Skip to main content

openIMIS Backend tasks_management reference module

This repository holds the files of the openIMIS Backend Task Managemet reference module. It is dedicated to be deployed as a module of openimis-be_py.

ORM mapping:

  • task_management_task, task_management_historicaltask > Task
  • task_management_taskgroup, task_management_historicaltaskgroup > TaskGroup
  • task_management_taskexecutor, task_management_historicaltaskexecutor > TaskExecutor
  • task_management_taskflow, task_management_historicaltaskflow > TaskFlow
  • task_management_taskflowstep, task_management_historicaltaskflowstep > TaskFlowStep
  • task_management_taskdecision, task_management_historicaltaskdecision > TaskDecision

GraphQl Queries

  • task, taskGroup, taskExecutor, taskFlow, taskDecision, taskAssignmentTargets

Services

  • Task
    • create
    • update
    • delete
    • complete_task
    • resolve_task
  • TaskGroup
    • create
    • update
    • delete
  • TaskExecutor
    • create
    • update
    • delete
  • CheckerLogicServiceMixin
    • create
    • update
    • delete
  • on_task_complete_service_handler

Configuration options (can be changed via core.ModuleConfiguration)

  • gql_task_group_search_perms: 190001
  • gql_task_group_create_perms: 190002
  • gql_task_group_update_perms: 190003
  • gql_task_group_delete_perms: 190004
  • gql_task_search_perms: 191001
  • gql_task_create_perms: 191002
  • gql_task_update_perms: 191003
  • gql_task_delete_perms: 191004
  • gql_task_flow_search_perms: 192001
  • gql_task_flow_create_perms: 192002
  • gql_task_flow_update_perms: 192003
  • gql_task_flow_delete_perms: 192004
  • default_executor_event: default
  • flow_ineligible_sources: claim_sampling
  • flow_batch_sources: import_valid_items, import_group_valid_items

openIMIS Modules Dependencies

  • core

Layered task approvals (approval flows)

A TaskFlow is a reusable, ordered sequence of TaskFlowSteps. Each step points at a TaskGroup used as its executor pool, and may override that group's completion policy (ALL / ANY / N+threshold) or inherit it. A task following a flow advances step by step - Task.flow and Task.current_step track its position, and Task.task_group is kept pointing at the active step's pool so existing executor-based visibility and filtering keep working unchanged. Every vote is recorded in TaskDecision, an insert-only ledger, before the step is evaluated.

A task reaches a flow one of two ways:

  • Automatically, when its source is bound to a flow's task_sources (TaskFlow.json_ext.task_sources) - the flow is matched at task creation time, ahead of the legacy task-group source binding.
  • Manually, via updateTask(flowId: ...) on an existing task - it is parked on the flow's first step, with its task group derived from that step's pool. updateTask(detachFlow: true) returns a task to a flat, group-only task. Both are refused once the task carries a TaskDecision, since decisions are recorded against the flow it was on.

TaskFlow is versioned via HistoryBusinessModel: editing a flow's steps replaces it (a new head version is created, the old one is superseded), so tasks already mid-review keep following the version they started on and only new tasks bind to the new head.

Role-rights (192001-192004) are not provisioned by a migration. Like the rest of this module's rights, insert_role_right_for_system is a deliberate no-op - core assigns rights from the Roles administration UI at deployment time, not from module code. A fresh deployment must grant these four rights to the appropriate roles there before any approval-flow screen becomes usable to anyone but a superuser.

Per-record batch sources follow flows too, on a separate path. flow_batch_sources (import_valid_items, import_group_valid_items) lists sources that submit a per-record verdict - {ACCEPT: [...], REJECT: [...]} - instead of one verdict for the whole task. A batch task's step evaluates by reviewers who have voted, not by counting approvals of a single subject: each TaskDecision is recorded per record per step, a record rejected at any step stays rejected for the rest of the flow, and the step (and the task) advances once enough distinct reviewers have submitted a verdict to satisfy the step's policy - the same ALL/ANY/N+threshold policies as a whole-task step. flow_rejected_record_ids(task) gives the consumer module the set of record ids rejected anywhere along the flow; the module applies its business action once, at task completion, to everything in the upload except those - mirroring the flat behaviour where a rejected row is simply left out.

Not every task source can join a flow. flow_ineligible_sources lists sources whose resolution is genuinely incompatible with either flow path - claim sampling (claim_sampling) does not fit the per-task or per-record verdict shape the flow engine expects. A flow match against one of these sources is skipped at creation, and a manual updateTask(flowId: ...) against one of their tasks is rejected.

Creating execution action handlers and business event handlers

When user action specified by the task is being passed to backend, the task service sends task_service.resolve_task signal. The approach for handler is to bind to after signal and check the specific executor_action_event of the task. The same approach is used for business event handlers, being required to bind on task_service.complete_task.

# in signals.py in any module
def bind_service_signals():
    bind_service_signal(
        'task_service.resolve_task',
        handler_hook,
        bind_type=ServiceSignalBindType.AFTER
    )

def handler_hook(**kwargs):
    pass

Creating tasks for BaseService implementations

CheckerLogicServiceMixin allows implementations of core.services.BaseService to generate tasks for create, update and delete actions. this adds create__task methods to the service, with the same API as the methods. Additionally the on_task_complete_service_handler service method allows to generate complete_task handlers for core.services.BaseService implementations.

# In service definition
class ExampleService(BaseService, CheckerLogicServiceMixin):
    ...

# to create a task instead of performing create operation, instead of:
# ExampleService(user).create(data)
ExampleService(user).create_create_task(data)
`
#in signals.py (any module, but the same module as service preferred)
def bind_service_signals():
    bind_service_signal(
        'task_service.complete_task',
        on_task_complete_service_handler(ExampleService),
        bind_type=ServiceSignalBindType.AFTER
    )

Metadata

Release files for openimis-be-tasks-management 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openimis-be-tasks-management 1.6.1
File Size Uploaded Provenance Actions
openimis_be_tasks_management-1.6.1.tar.gz 71.1 kB Without provenance Details for openimis_be_tasks_management-1.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openimis-be-tasks-management 1.6.1
File Interpreter ABI Platform Actions
openimis_be_tasks_management-1.6.1-py3-none-any.whl Python 3 none any Details for openimis_be_tasks_management-1.6.1-py3-none-any.whl

Total release size: 162.8 kB

Release files / openimis_be_tasks_management-1.6.1.tar.gz

Download URL openimis_be_tasks_management-1.6.1.tar.gz
Size 71.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6e5a6da2fabf0f20a67cc14587803250a2b0ee0a97f4f1497e8743221b605bea
BLAKE2b-256 checksum
How to use checksums
1cb91e9f835b9d49e2089e45c2338040558d238bd33f6d690248dfed82356443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / openimis_be_tasks_management-1.6.1-py3-none-any.whl

Download URL openimis_be_tasks_management-1.6.1-py3-none-any.whl
Size 91.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2011e849b1c3e318eb083937472d95465a24225a96aff19812077332010c6c55
BLAKE2b-256 checksum
How to use checksums
a87b89192d6f85d429974f4d182f0d02a8023dd9014c6a97139e75849d52e37d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for openimis-be-tasks-management 1.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page