mafw.processor.processor_list
ProcessorList container for orchestrating sequences of processors.
This module defines ProcessorList, a specialised list that holds
Processor instances (or nested ProcessorLists) and
executes them sequentially. It manages shared resources — timer, user interface,
and database connection — distributing them to each processor before execution.
Scientists typically construct a ProcessorList in their analysis script,
populate it with processor instances representing successive analysis steps, and
call execute() to run the full pipeline.
Added in version 2.3: Extracted from the monolithic processor.py module for improved
maintainability and focused testing.
Classes
|
A list like collection of processors. |
- class mafw.processor.processor_list.ProcessorList(*args: mafw.processor.Processor | ProcessorList, name: str | None = None, description: str | None = None, timer: Timer | None = None, timer_params: dict[str, Any] | None = None, user_interface: UserInterfaceBase | None = None, database: Database | None = None, storage_service: mafw.storage.StorageService | None = None, database_conf: dict[str, Any] | None = None, database_environment: Mapping[str, str] | None = None, create_standard_tables: bool = True, path_resolution_context: PathResolutionContext | None = None, path_resolution_managed: bool = False)[source]
Bases:
list[mafw.processor.Processor | ProcessorList]A list like collection of processors.
ProcessorList is a subclass of list containing only
Processorsubclasses or other ProcessorLists.An attempt to add an element that is not a
Processoror a ProcessorList will raise a TypeError.Along with an iterable of processors, a new processor list can be built using the following parameters.
A root list initializes its attached storage service after acquiring the database and creating standard tables. Nested lists and processors borrow that same initialized service.
Changed in version 2.4: Added optional runtime storage-service attachment.
Constructor parameters:
- Parameters:
name (str, Optional) – The name of the processor list. Defaults to ProcessorList.
description (str, Optional) – An optional short description. Default to ProcessorList.
timer (Timer, Optional) – The timer object. If None is provided, a new one will be created. Defaults to None.
timer_params (dict, Optional) – A dictionary of parameter to build the timer object. Defaults to None.
user_interface (UserInterfaceBase, Optional) – A user interface. Defaults to None
database (Database, Optional) – A database instance. Defaults to None.
storage_service (mafw.storage.StorageService | None) – Storage service borrowed or initialized by this list.
database_conf (dict, Optional) – Configuration for the database. Default to None.
database_environment (Mapping[str, str], Optional) – Optional environment mapping used to resolve steering database settings.
create_standard_tables (bool, Optional) – Whether or not to create the standard tables. Defaults to True.
path_resolution_context (PathResolutionContext, Optional) – Owning steering-file context for known path parameters.
path_resolution_managed (bool) – Whether processors without a context are framework-managed.
- static validate_item(item: mafw.processor.Processor | ProcessorList) mafw.processor.Processor | ProcessorList[source]
Validates the item being added.
- static validate_items(items: tuple[mafw.processor.Processor | ProcessorList, ...] = ()) tuple[mafw.processor.Processor | ProcessorList, ...][source]
Validates a tuple of items being added.
- _bind_path_context(item: mafw.processor.Processor | ProcessorList) None[source]
Propagate the owning steering context through nested groups.
- _bind_storage_service(item: mafw.processor.Processor | ProcessorList) None[source]
Propagate this list’s service without replacing a conflicting attachment.
- acquire_resources() None[source]
Acquires external resources.
The resource acquisition strategy mirrors
processor.Processor.acquire_resources(): if a resource (timer, database) is already provided, it is reused; otherwise a new one is created and registered with the exit stack for automatic cleanup.
- append(_ProcessorList__object: mafw.processor.Processor | ProcessorList) None[source]
Appends a new processor at the end of the list.
- distribute_resources(processor: mafw.processor.Processor | Self) None[source]
Distributes the external resources to the items in the list.
- execute() ProcessorExitStatus[source]
Execute the list of processors.
Similarly to the
processor.Processor, ProcessorList can be executed. In simple words, the execute method of each processor in the list is called exactly in the same sequence as they were added.
- extend(_ProcessorList__iterable: Iterable[mafw.processor.Processor | ProcessorList]) None[source]
Extends the processor list with a list of processors.
- insert(_ProcessorList__index: SupportsIndex, _ProcessorList__object: mafw.processor.Processor | ProcessorList) None[source]
Adds a new processor at the specified index.
- create_standard_tables
The boolean flag to proceed or skip with standard table creation and initialisation
- property database: Database
Returns the database instance
- Returns:
A database instance
- Raises:
MissingDatabase – if a database connection is missing.
- property name: str
The name of the processor list
- Returns:
The name of the processor list
- Return type:
str
- nested_list
Boolean flag to identify that this list is actually inside another list.
Similarly to the local resource flag for the
Processor, this flag prevents the user interface to be added to the resource stack.
- property processor_exit_status: ProcessorExitStatus
The processor exit status.
It refers to the whole processor list execution.
- storage_service
Optional storage service shared with this list’s processors.
Only a root list owns initialization. A nested list must inherit its service from its root, and conflicting attachments raise
ValueError.