ImpressBasePipeline¶
impress.pipelines.impress_pipeline.ImpressBasePipeline
¶
Bases: ABC
Abstract base class for all IMPRESS pipelines.
Subclasses implement register_pipeline_tasks() to bind task methods
(via auto_register_task()) and run() to define the pipeline's
control flow, and may optionally override finalize() for cleanup. The
base class provides the adaptive
execution protocol (run_adaptive_step()) and the child-pipeline
request mechanism (submit_child_pipeline_request() /
get_child_pipeline_request()) used by ImpressManager to support
dynamic, self-spawning pipeline trees.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Pipeline instance name. |
|
flow |
The |
|
state |
Free-form dict for passing data between pipeline stages. |
|
config |
Extra keyword arguments captured at construction time. |
|
kill_parent |
When set to True, the manager cancels this pipeline's task on its next poll. |
|
invoke_adaptive_step |
When True, the manager runs this pipeline's adaptive function on its next poll. |
|
incoming_child_pipeline_request |
Pending child-pipeline submission
request, populated by |
Source code in src/impress/pipelines/impress_pipeline.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
telemetry
property
¶
The running telemetry manager, or None when telemetry is off.
ImpressManager sets it before run(). A pipeline driven without the
manager has none unless the caller sets _telemetry itself.
__init__(name, flow=None, **config)
¶
Initialize the pipeline and register its tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Pipeline instance name. |
required |
flow
|
The |
None
|
|
**config
|
Additional configuration stored in |
{}
|
Source code in src/impress/pipelines/impress_pipeline.py
auto_register_task(local_task=False, capture_stdio=True, **task_kwargs)
¶
Decorator factory that binds a task function as a callable pipeline method.
Used inside register_pipeline_tasks() to register the coroutines
that make up a pipeline's stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_task
|
If False (default), wraps the function via
|
False
|
|
capture_stdio
|
For executable tasks, write the task's stdout and stderr to files in the backend's work dir (default True). The task's future then resolves to the stdout file path, not the stdout text. Pass False to get the text back. |
True
|
|
**task_kwargs
|
Forwarded to |
{}
|
Executable tasks get two more behaviours:
- Each call is labelled
{pipeline}:{stage}in telemetry unless the caller passes its ownworkflow_id=. Without a label, asyncflow names a task after its executable, which is usuallybash. - When a task fails, the last lines of its captured stderr are logged, and attached to the exception as a note (Python 3.11+).
Returns:
| Type | Description |
|---|---|
|
A decorator that binds the wrapped function to |
|
|
own name (so it becomes callable as |
Source code in src/impress/pipelines/impress_pipeline.py
finalize()
async
¶
Cleanup or finalization logic.
Optional extension point; the default implementation is a no-op. Typically called by subclass-specific adaptive logic (for example, after spawning a child pipeline) to update or clear tracking state on the parent pipeline.
Source code in src/impress/pipelines/impress_pipeline.py
get_child_pipeline_request()
¶
Get and clear any pending spawn request for child pipelines.
Returns:
| Type | Description |
|---|---|
|
dict or None: The spawn request configuration if one exists, None otherwise. After calling this method, the spawn request is cleared. |
Source code in src/impress/pipelines/impress_pipeline.py
get_current_config_for_next_pipeline()
¶
Build a default configuration dict for a follow-on pipeline.
Optional extension point; subclasses can override this to build the
config dict passed to submit_child_pipeline_request(). Returns a
generic default pointing at the same pipeline class.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Configuration with at least |
Source code in src/impress/pipelines/impress_pipeline.py
get_scores_map()
async
¶
Return a mapping of scores for this pipeline.
Optional extension point; subclasses may override this to expose fitness/quality scores to external callers. Returns an empty dict by default.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping of score name to value. |
Source code in src/impress/pipelines/impress_pipeline.py
logged_command(log_file, cmd)
¶
Wrap cmd so its combined output lands in log_file.
For a per-task log next to the task's outputs. On failure the log's last lines also go to stderr, and so into the task's error.
Source code in src/impress/pipelines/impress_pipeline.py
register_pipeline_tasks()
abstractmethod
¶
Register pipeline tasks; must be implemented by subclasses.
Called once, synchronously, from __init__ before anything else
runs. Implementations use @self.auto_register_task() to bind task
coroutines as callable methods on self for use in run().
Source code in src/impress/pipelines/impress_pipeline.py
run()
abstractmethod
async
¶
Main execution method; must be implemented by subclasses.
Drives the pipeline's control flow: calling task methods registered
in register_pipeline_tasks(), and calling
await self.run_adaptive_step(...) at decision points where the
pipeline should evaluate intermediate results and optionally spawn
child pipelines.
Source code in src/impress/pipelines/impress_pipeline.py
run_adaptive_step(wait=True)
async
¶
Trigger adaptive step and optionally wait for completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait
|
bool
|
If True, waits for adaptive step completion. If False, triggers and returns immediately. |
True
|
Source code in src/impress/pipelines/impress_pipeline.py
submit_child_pipeline_request(pipeline_config)
¶
Submit a request to spawn a child pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_config
|
dict
|
Configuration for the new pipeline including 'name', 'type', 'config', and 'adaptive_fn' |
required |