cmem_client.repositories.workflows¤
Repository for the workflows of DataIntegration projects.
Provides WorkflowsRepository for listing workflows and for starting them, polling their execution status, running them with input or output payloads and reading their execution reports.
Examples:
List the workflows of the deployment:
>>> from cmem_client.client import Client
>>> client = Client.from_env()
>>> for workflow_id in client.workflows:
... print(workflow_id, client.workflows[workflow_id].label)
Start a workflow and wait until it finished:
>>> client.workflows.execute("my-project:my-workflow")
>>> client.workflows.get_status("my-project:my-workflow")
>>> client.workflows.execute_wait_for_completion("my-project:my-workflow")
Look at the status of every workflow currently known:
List the execution reports of a workflow and fetch the latest one:
>>> reports = client.workflows.list_reports("my-project:my-workflow")
>>> client.workflows.get_report("my-project:my-workflow", reports[0].time)
Classes:
- WorkflowsRepository – Repository for managing workflows in eccenca Corporate Memory.
WorkflowsRepository¤
Bases: TaskSearchRepository
Repository for managing workflows in eccenca Corporate Memory.
The dict (keys, values, items) is populated via the task search API, which returns the workflows with their tags in a single call, and the workflow info API, which resolves their variable inputs and outputs (variableInputs/variableOutputs). Operational methods (execute, get_status, execute_io, etc.) are independent of the dict and hit dedicated activity/result endpoints.
Functions:
- execute – Execute the workflow without waiting for completion.
- execute_io – Execute a workflow with variable input/output as a streaming context manager.
- execute_wait_for_completion – Execute the workflow and block until it finishes.
- execute_with_variables – Execute the workflow once with overridden execution variables.
- fetch_data – Fetch the workflows and complete their variable inputs and outputs.
- get_all_statuses – Get status information for multiple workflow activities.
- get_execution_variables – Get the execution variables a run of the workflow needs.
- get_report – Get one execution report of a workflow.
- get_status – Get the current status of a workflow activity.
- get_task – Get full task details from the API.
- get_workflow_editor_url – Get the URL to open a workflow in the workbench editor.
- items – Get the items of the repository
- keys – Get the keys of the repository
- list_reports – List the execution reports available for a workflow.
- remove_execution – Remove a finished run started with
execute_with_variables(). - values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
execute¤
Execute the workflow without waiting for completion.
Parameters:
- workflow_id (
str) – The workflow to execute (in the form of ‘project_id:workflow_id’) - activity_name (
ACTIVITY_NAME) – Name of the activity
Raises:
WorkflowExecutionError– If the workflow execution failed.
execute_io¤
execute_io(workflow_id, input_file=None, input_mime_type='application/xml', output_mime_type='application/xml', auto_config=False, execution_variables=None)
Execute a workflow with variable input/output as a streaming context manager.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:task_id’. - input_file (
str | None) – Optional path to the input file. - input_mime_type (
str) – MIME type of the input file. - output_mime_type (
str) – MIME type expected for the output. - auto_config (
bool) – Whether to enable auto-configuration of input datasets. - execution_variables (
dict[str, str] | None) – Values by variable name, overriding the defaults of the workflow’s execution variables for this run only. They are never part of the input entity.
Yields:
Generator[Response]– httpx.Response: Streaming response from the workflow execution.
Raises:
WorkflowExecutionError– If the request fails.
execute_wait_for_completion¤
Execute the workflow and block until it finishes.
Parameters:
- workflow_id (
str) – The workflow to execute (in the form of ‘project_id:workflow_id’) - activity_name (
ACTIVITY_NAME) – Activity name. Defaults to “ExecuteDefaultWorkflow”. - sleep_time (
int) – Seconds to sleep between status polls. Defaults to 1.
Raises:
WorkflowExecutionError– If workflow execution failed.
execute_with_variables¤
Execute the workflow once with overridden execution variables.
The given values replace the defaults of the workflow’s execution variables for
this run only, the stored defaults stay unchanged. The run is started as an
instance of the ExecuteWorkflowWithPayload activity, so poll its status with
get_status() and that activity name and instance ID. The server keeps a
limited number of these instances per workflow, so remove a finished one with
remove_execution().
The server neither rejects names which the workflow does not use nor checks
for missing required variables, so compare the values with
get_execution_variables() beforehand if needed.
Parameters:
- workflow_id (
str) – The workflow to execute (in the form of ‘project_id:workflow_id’) - execution_variables (
dict[str, str]) – Values by variable name, overriding the defaults.
Returns:
str– The ID of the started activity instance.
Raises:
WorkflowExecutionError– If the workflow could not be started.
fetch_data¤
Fetch the workflows and complete their variable inputs and outputs.
The task search only carries the replaceable datasets marked on a workflow itself, so a workflow of workflows whose variable input or output sits in a nested workflow would report none. The workflow info endpoint resolves nested workflows as well, so its answer replaces the io information of every workflow.
Raises:
WorkflowReadError– If the workflow info request fails.
get_all_statuses¤
Get status information for multiple workflow activities.
Parameters:
- project_id (
str | None) – Optional project ID to filter by. - status_filter (
str | None) – Optional status filter (e.g. “Finished”, “Running”). - activity_type (
str | None) – Optional activity type to filter by (e.g. “ExecuteDefaultWorkflow”).
Returns:
list[WorkflowStatus]– List of WorkflowStatus objects.
Raises:
WorkflowReadError– If the status fetch request fails.
get_execution_variables¤
Get the execution variables a run of the workflow needs.
This covers the variables used at execution time by the workflow’s tasks and sub-workflows, recursively, and the variables defined on the workflow itself. Only the defaults defined on the workflow apply to a run, so a variable which is used but neither has such a default nor is set by a preceding node is marked as required.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:workflow_id’.
Returns:
list[WorkflowExecutionVariable]– The execution variables, sorted by name.
Raises:
WorkflowReadError– If the workflow does not exist or the request fails.
get_report¤
Get one execution report of a workflow.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:task_id’. - time (
datetime) – Timestamp of the report, as returned by list_reports.
Returns:
WorkflowReport– The execution report.
Raises:
WorkflowReadError– If the report could not be fetched.
get_status¤
Get the current status of a workflow activity.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:workflow_id’. - activity_name (
ACTIVITY_NAME) – Activity to check. Defaults to “ExecuteDefaultWorkflow”. - instance_id (
str | None) – Activity instance to check, e.g. the one returned byexecute_with_variables(). Defaults to the main instance.
Returns:
WorkflowStatus– WorkflowStatus with current state, progress, and message.
Raises:
WorkflowReadError– If the status fetch request fails.
get_task¤
Get full task details from the API.
Parameters:
- project_id (
str) – The project ID. - task_id (
str) – The task ID. - with_labels (
bool) – Whether to include labels in the response.
Returns:
TaskResponse– The full task details as a TaskResponse model.
get_workflow_editor_url¤
Get the URL to open a workflow in the workbench editor.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:task_id’.
Returns:
str– URL string for the workflow editor.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
list_reports¤
List the execution reports available for a workflow.
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:task_id’.
Returns:
list[WorkflowReportInfo]– The reports available for the workflow. Empty if it was never executed.
Raises:
WorkflowReadError– If the report list could not be fetched.
logger¤
Gets the client logger
remove_execution¤
Remove a finished run started with execute_with_variables().
Parameters:
- workflow_id (
str) – Workflow ID in the form ‘project_id:workflow_id’. - instance_id (
str) – The activity instance ID of the run.
Raises:
WorkflowExecutionError– If the request fails.
values¤
Get the values of the repository