Execution¶
The scheduling abstraction dispatching one job per recording — sequentially, or in parallel via Dask.
execution
¶
Execution backends for dispatching one pipeline job per recording.
MEEGFlow's job manager (MEEGFlowPipeline.run_pipeline) discovers the list
of recordings to process, then dispatches one self-contained job per
recording through the backend selected here:
sequential(default): today's single-process, in-order loop. Requires no new dependency.local: an in-process Dask cluster (distributed.LocalCluster), comparable toconcurrent.futures.ProcessPoolExecutororjoblib.slurm/pbs/sge/lsf/htcondor: adask-jobqueuecluster, submitting one Dask worker job per HPC scheduler job.
dask and dask-jobqueue are optional dependencies (see
extras_require in setup.py) and are only imported lazily, inside the
functions that need them, so importing this module (and therefore
meegflow.pipeline) never requires Dask to be installed unless a
non-sequential backend is actually requested.
See docs/dask_parallel_execution.md for the full design rationale.
ExecutionConfig
dataclass
¶
Execution backend selection, parsed from the execution config block.
Parameters¶
backend : str
One of 'sequential' (default), 'local', or a
dask-jobqueue cluster type ('slurm', 'pbs', 'sge',
'lsf', 'htcondor').
n_workers : int
Number of parallel workers (local processes, or cluster jobs).
Ignored for the sequential backend.
cluster_kwargs : dict
Extra keyword arguments forwarded verbatim to the underlying Dask
cluster constructor (e.g. queue, cores, memory,
walltime for dask-jobqueue backends).
Source code in src/meegflow/execution.py
from_config
classmethod
¶
Parse the execution block of a pipeline config, if present.
Parameters¶
config : dict or None
The full pipeline configuration dictionary. Recognizes a top-level
execution mapping with keys backend, n_workers, and
cluster_kwargs. Missing or absent -> sequential execution.
Returns¶
ExecutionConfig
Source code in src/meegflow/execution.py
run_sequential
¶
Process recordings one at a time, in this process (today's default behavior).
Parameters¶
recordings : list of dict
Output of reader.find_recordings(...).
reader : DatasetReader
Reader used to load each recording's files.
output_root : str or Path, optional
Derivatives root override.
config : dict
Full pipeline configuration.
step_functions : dict
Mapping of step name -> callable (built-in + custom).
io_backend : str
MNE IO backend used to read raw files.
Returns¶
all_results : dict
Mapping {subject: [result_or_error, ...]}, matching the shape
returned by run_dask.
Source code in src/meegflow/execution.py
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 | |
run_dask
¶
Dispatch one job per recording through a Dask cluster.
Used for the local backend and every dask-jobqueue backend
(slurm, pbs, sge, lsf, htcondor). Preserves the
sequential backend's contract: one recording's failure is captured as an
{'error': ...} entry rather than aborting the batch, and results are
returned in the same {subject: [result, ...]} shape as
:func:run_sequential.
Parameters¶
recordings : list of dict
Output of reader.find_recordings(...).
reader : DatasetReader
Reader used to load each recording's files. Must be picklable.
output_root : str or Path, optional
Derivatives root override.
config : dict
Full pipeline configuration (plain, picklable dict).
io_backend : str
MNE IO backend used to read raw files.
exec_config : ExecutionConfig
Selects and configures the Dask cluster (backend, worker count,
cluster-specific kwargs).
Returns¶
all_results : dict
Mapping {subject: [result_or_error, ...]}.
Source code in src/meegflow/execution.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
dispatch
¶
Dispatch one job per recording, routing to the backend named in exec_config.