|
30 | 30 | from cmem_plugin_loopwf import exceptions |
31 | 31 | from cmem_plugin_loopwf.workflow_type import SuitableWorkflowParameterType |
32 | 32 |
|
33 | | -DOCUMENTATION = """This workflow task operates on a list of incoming entities |
34 | | -and starts a single "inner" workflow for each entity. The task supports |
35 | | -both sequential and parallel execution modes. |
36 | | -
|
37 | | -## Core Functionality |
38 | | -
|
39 | | -- **Entity Processing**: Converts each input entity to JSON format and passes |
40 | | - it to the selected sub-workflow as replaceable input data |
41 | | -- **Execution Modes**: Supports both sequential (default) and parallel execution |
42 | | - with configurable concurrency levels |
43 | | -- **File Processing (Beta)**: Can process file entities directly by passing file |
44 | | - content instead of metadata when `input_mime_type` is configured |
45 | | -- **Error Handling**: If any inner workflow fails, the entire execution stops |
46 | | - with an error. Error details can be seen in the Activities view |
47 | | -- **Output Control**: Can optionally forward input entities to the output port |
48 | | -
|
49 | | -## Configuration Options |
50 | | -
|
51 | | -- **Workflow Selection**: Choose from workflows in the current project that have |
52 | | - exactly one replaceable input dataset |
53 | | -- **Parallel Execution**: Control how many workflows run simultaneously (default: 1) |
54 | | -- **Entity Forwarding**: Choose whether to pass input entities to the output port |
55 | | -- **MIME Type**: For file processing, specify the content type to send file data |
56 | | - instead of metadata (supports formats like JSON, XML, CSV, Excel, etc.) |
57 | | -
|
58 | | -## Workflow Requirements |
59 | | -
|
60 | | -The selected inner workflow must: |
61 | | -- Exist in the same project as this task |
62 | | -- Have exactly one replaceable input dataset (JSON format) |
63 | | -- Be designed to handle the entity structure provided by the input |
64 | | -
|
65 | | -## Current Limitations |
66 | | -
|
67 | | -- Input entities cannot be hierarchical (flat structure only) |
68 | | -- The replaceable dataset of the inner workflow must be a JSON dataset |
69 | | -- No circular dependency detection is implemented |
70 | | -- File processing feature is in beta and requires proper MIME type configuration |
71 | | -
|
72 | | -## Use Cases |
73 | | -
|
74 | | -- **Data Processing Pipelines**: Process each record through a complex workflow |
75 | | -- **Batch Operations**: Apply transformations to multiple entities individually |
76 | | -- **Quality Assurance**: Run validation workflows on each data item |
77 | | -- **Export/Integration**: Process entities through different output workflows |
| 33 | +DOCUMENTATION = """Run another workflow once per incoming entity. |
| 34 | +
|
| 35 | +## Overview |
| 36 | +
|
| 37 | +- **Per-entity execution**: For every entity on the input port, this task starts one selected sub-workflow. |
| 38 | +- **Execution modes**: Runs sequentially by default or in parallel with a configurable concurrency. |
| 39 | +- **Input handover**: Each entity is converted to a JSON object and provided to the sub-workflow via its single replaceable (variable) input dataset. |
| 40 | +- **Optional pass-through**: Optionally forwards the original input entities to the output port; it never returns results produced by the sub-workflow. |
| 41 | +- **File support (beta)**: When processing file entities and a `input_mime_type` is set, the file content is sent to the sub-workflow instead of the file metadata. |
| 42 | +
|
| 43 | +## How It Works |
| 44 | +
|
| 45 | +1. Read entities from the single input port (flexible schema). |
| 46 | +2. Convert each entity to a flat JSON object using the entity schema (one value per path required). |
| 47 | +3. Start the chosen sub-workflow once per entity, supplying the JSON as the replaceable input dataset. |
| 48 | +4. Run up to `parallel_execution` workflow instances at the same time. |
| 49 | +5. Stop with an error if any sub-workflow fails; see details in Activities. |
| 50 | +
|
| 51 | +Example entity mapping (illustrative): |
| 52 | +Input schema paths: `label`, `id` → JSON payload: `{ "label": "Example", "id": "123" }` |
| 53 | +
|
| 54 | +## Parameters |
| 55 | +
|
| 56 | +- **Workflow**: Workflow from the same project that exposes exactly one replaceable (variable) input dataset. That dataset must accept JSON or file content as configured below. |
| 57 | +- **How many workflow jobs should run in parallel?**: Integer ≥ 1. Controls the maximum number of concurrently running sub-workflows. |
| 58 | +- **Forward incoming entities to the output port?**: When enabled, forwards the original input entities. When disabled, produces no output entities. |
| 59 | +- **Mime-type for file by file processing (beta)**: For file entities only. If set (e.g., `application/json`, `application/xml`, `text/csv`, `application/octet-stream`, `application/x-plugin-excel`), the raw file content is sent to the sub-workflow instead of metadata. |
| 60 | +
|
| 61 | +## Requirements |
| 62 | +
|
| 63 | +- The selected workflow must be in the same project as this task. |
| 64 | +- The selected workflow must have exactly one replaceable input dataset (also called a variable input). |
| 65 | +- The input entities must be flat: each schema path may have at most one value per entity. |
| 66 | +
|
| 67 | +## Limitations |
| 68 | +
|
| 69 | +- Nested or multi-valued entities are not supported; multiple values per path raise an error. |
| 70 | +- The replaceable dataset of the sub-workflow must match the provided data type (JSON or file content depending on configuration). |
| 71 | +- No circular dependency detection is performed. |
| 72 | +- File processing is beta; correct `input_mime_type` and a file-accepting dataset in the sub-workflow are required. |
| 73 | +
|
| 74 | +## Troubleshooting |
| 75 | +
|
| 76 | +- "Need a connected input task": Connect one upstream task to provide entities. |
| 77 | +- "Can process a single input only": Only one input port is supported. |
| 78 | +- "Multiple values for entity path": Ensure each path has at most one value. |
| 79 | +- "Workflow ... does not exist ... or is missing a single replaceable input dataset": Select a workflow in the same project with exactly one variable input. |
| 80 | +
|
| 81 | +## Typical Uses |
| 82 | +
|
| 83 | +- Per-record processing pipelines (e.g., validation, enrichment, export). |
| 84 | +- Batch operations that require complex per-entity logic encapsulated in a workflow. |
| 85 | +- Quality checks where each entity must pass through a dedicated validation workflow. |
78 | 86 | """ |
79 | 87 |
|
80 | 88 |
|
|
0 commit comments