mafw.steering_gui.controllers.steering_controller

Application layer controller for steering configuration builds.

Author:

Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)

Description:

Keep GUI and execution logic isolated while managing SteeringBuilder state.

Module Attributes

P

Type variable capturing the positional parameters of the wrapped method.

R

Type variable capturing the return type of the wrapped method.

Functions

build_database_connection_configuration(config)

Return a normalized configuration dict for connection checks.

recorded_mutation(method)

Decorator that records the controller state before mutating operations.

Classes

DirtyStateSignal()

Lightweight notifier for controller dirty-state transitions.

SteeringController([builder, max_history, ...])

Controller orchestrating SteeringBuilder without GUI or execution ties.

Exceptions

SteeringControllerError

Raised when the controller is asked to perform an invalid operation.

exception mafw.steering_gui.controllers.steering_controller.SteeringControllerError[source]

Bases: MAFwException

Raised when the controller is asked to perform an invalid operation.

class mafw.steering_gui.controllers.steering_controller.DirtyStateSignal[source]

Bases: object

Lightweight notifier for controller dirty-state transitions.

connect(callback: Callable[[bool], None]) None[source]

Subscribe to dirty-state change notifications.

emit(value: bool) None[source]

Notify every subscriber about the new dirty value.

class mafw.steering_gui.controllers.steering_controller.R

Type variable capturing the return type of the wrapped method.

alias of TypeVar(‘R’)

class mafw.steering_gui.controllers.steering_controller.SteeringController(builder: SteeringBuilder | None = None, *, max_history: int | None = None, plugin_manager: MAFwPluginManager | None = None)[source]

Bases: object

Controller orchestrating SteeringBuilder without GUI or execution ties.

classmethod from_file(path: Path | str) SteeringController[source]

Instantiate a controller from an existing steering file.

static _normalize_schema_default(value: Any) Any[source]

Convert schema defaults into serializable values.

_assemble_connection_source(overrides: dict[str, Any] | None = None) dict[str, Any][source]

Combine controller-managed attributes with override input.

_mark_clean() None[source]

Mark the controller as clean and notify subscribers.

_unique_processor_name(base_name: str) tuple[str, str | None][source]

Return a unique processor name and replica identifier for the requested base.

_write_to_path(path: Path) None[source]

Serialize the builder to the provided path.

add_group(name: str, processors: Iterable[str], description: str | None = None) None[source]

Declare a new group section.

add_group_entry_to_group(target_group: str, entry_name: str) None[source]

Append a processor or group reference to a group list.

add_group_to_run_list(name: str) None[source]

Append a group name to the processors_to_run list if missing.

add_processor_to_run_list(base_name: str, replica: str | None = None) None[source]

Add a processor or replica to the execution list and ensure its section exists.

add_processors_to_group_with_defaults(group_name: str, base_names: Iterable[str]) None[source]

Append processors to a group and set their parameters to schema defaults.

add_processors_with_defaults(base_names: Iterable[str]) None[source]

Append processors to the run list and set their parameters to schema defaults.

add_replica(base_name: str, replica: str) None[source]

Ensure a replica section exists without altering parameters.

available_db_module_count() int | None[source]

Return how many database modules have been loaded (or None until available).

available_processor_count() int | None[source]

Return how many processor plugins have been loaded (or None until available).

available_processor_names() list[str][source]

Return the available processor names from loaded plugins.

available_ui_count() int | None[source]

Return how many user interface plugins have been loaded (or None until available).

build_connection_test_task(config: dict[str, Any] | None = None) Callable[[], bool][source]

Return a callable that validates the current database settings via Peewee.

Parameters:

config – Optional overrides supplied by the GUI connection tester.

Returns:

Callable that returns True when the connection is verified; it raises on failure.

build_pipeline(*, progress_callback: Callable[[int], None] | None = None) ProcessorPipeline[source]

Build the in-memory pipeline tree for the steering GUI.

can_redo() bool[source]

Return whether a previously undone state can be re-applied.

can_undo() bool[source]

Return whether the controller can revert to a previously recorded state.

clear_processor_parameters(full_name: str) None[source]

Clear every parameter override for a processor.

current_file() Path | None[source]

Return the file currently associated with persistence operations.

disable_db_configuration() None[source]

Disable the DBConfiguration section so it is omitted when written.

enable_db_configuration() None[source]

Enable the DBConfiguration section for serialization.

ensure_valid(validation_level: ValidationLevel = ValidationLevel.SEMANTIC) None[source]

Raise the first validation issue or return silently when the builder is valid.

export_to_path(path: Path | str) None[source]

Serialize the builder to the provided path without validation.

get_analysis_description() str | None[source]

Return the configured analysis_description safely.

get_analysis_name() str | None[source]

Return the configured analysis_name without exposing the builder.

get_create_standard_tables() bool | None[source]

Return the create_standard_tables flag.

get_db_attributes() dict[str, Any][source]

Return a copy of the database attributes map.

get_db_pragmas() dict[str, Any][source]

Return a copy of the DB pragmas map.

get_db_url() str | None[source]

Return the configured database URL.

get_globals() dict[str, Any][source]

Return the globals metadata used by the UI.

get_group_attributes(name: str) dict[str, Any][source]

Return a copy of a group’s attributes.

get_group_snapshot(name: str) GroupConfig[source]

Return a copy of a group configuration.

get_new_only() bool | None[source]

Return the current new_only flag.

get_processor_snapshot(full_name: str) ProcessorConfig[source]

Return a deep copy snapshot of a processor configuration.

get_processors_to_run() list[str][source]

Return a copy of the ordered processor references.

get_ui_interface() str[source]

Return the configured UI interface identifier.

is_db_configuration_enabled() bool[source]

Return whether the DBConfiguration section will appear in serialized output.

list_groups() list[str][source]

Return the declared group section names.

list_processors() list[str][source]

Return the known processor section names.

load(path: Path | str) None[source]

Load steering metadata from disk, replace the current builder, and rebase the reset snapshot.

load_plugins() LoadedPlugins[source]

Load the asynchronous plugin bundles and cache the result for GUI consumers.

Returns:

Plugins container with available processors, database modules, and UIs

Return type:

LoadedPlugins

move_pipeline_entry(entry_name: str, entry_is_group: bool, source_group: str | None, target_group: str | None, position: int) None[source]

Move a pipeline entry across parents and adjust execution ordering.

move_processor_in_run_list(full_name: str, position: int) None[source]

Move a scheduled processor to a concrete slot in the execution order.

redo() None[source]

Re-apply the last undone snapshot.

remove_filter(full_name: str, model_name: str) None[source]

Delete a filter model definition.

remove_group(name: str) None[source]

Delete a named group section.

remove_pipeline_entries(names: Iterable[str]) None[source]

Remove pipeline entries from the top-level processors_to_run list.

remove_pipeline_entry(entry_name: str, source_group: str | None) None[source]

Remove a pipeline entry from the top-level or a group list.

remove_processor_from_run_list(full_name: str) None[source]

Remove a processor reference from the execution order.

remove_processor_parameter(full_name: str, key: str) None[source]

Remove a processor parameter override if present.

rename_group(old_name: str, new_name: str) None[source]

Rename a group and update all pipeline references.

rename_processor_entry(old_name: str, new_name: str, source_group: str | None) None[source]

Rename a processor reference and keep its configuration aligned.

replace_builder(builder: SteeringBuilder) None[source]

Replace the current builder with the provided instance.

reset() None[source]

Restore the controller to its initial state and clear history.

reset_processor_parameters(full_name: str) None[source]

Reset the processor parameters to their default values without dropping the overrides.

save(*, skip_validation: bool = False) None[source]

Persist the current steering state to the associated file path.

save_as(path: Path | str, *, skip_validation: bool = False) None[source]

Persist the current steering state to a new file path and track it.

set_analysis_description(value: str | None) None[source]

Update the top-level analysis_description setting.

set_analysis_name(value: str | None) None[source]

Update the top-level analysis_name setting.

set_create_standard_tables(value: bool | None) None[source]

Update the create_standard_tables flag.

set_db_attribute(key: str, value: Any | None) None[source]

Update a single entry stored under DBConfiguration.

set_db_pragmas(pragmas: Mapping[str, Any]) None[source]

Replace the DB pragmas map with a copy of the provided mapping.

set_db_url(value: str | None) None[source]

Update the DB URL while keeping builder semantics.

set_filter_conditionals(full_name: str, model_name: str, conditionals: list[Mapping[str, Any]] | None) None[source]

Assign __conditional__ blocks to a filter model.

set_filter_config(full_name: str, model_name: str, config: Mapping[str, Any]) None[source]

Replace a filter model configuration with a copy of the provided mapping.

set_filter_field(full_name: str, model_name: str, field: str, value: Any) None[source]

Set or update a single filter field.

set_filter_logic(full_name: str, logic: str | None) None[source]

Update the __logic__ string for a processor’s filters.

set_group_attributes(name: str, attributes: Mapping[str, Any]) None[source]

Replace a group’s attributes with a new copy.

set_group_description(name: str, description: str | None) None[source]

Set or clear the description for a group.

set_group_processors(name: str, processors: Iterable[str]) None[source]

Replace the processors list for the given group.

set_new_only(value: bool | None) None[source]

Update the new_only flag.

set_processor_filters(full_name: str, filters: Mapping[str, Iterable[FilterConfig]], logic: str | None) None[source]

Replace the whole filter dictionary and logic for a processor.

set_processor_new_only(full_name: str, value: bool | None) None[source]

Set the __new_only__ override for a processor section.

set_processor_parameter(full_name: str, key: str, value: Any) None[source]

Update a single processor parameter.

set_processors_to_run(processors: Iterable[str]) None[source]

Overwrite the processors_to_run list while keeping a copy of the iterable.

set_replica_inheritance(replica_full_name: str, value: bool | None) None[source]

Toggle replica inheritance.

set_ui_interface(interface: str) None[source]

Update the selected UI interface (neutral placeholder, no GUI imports).

set_validation_level(level: ValidationLevel | None) None[source]

Keep track of the validation level preference without affecting builder data.

undo() None[source]

Revert the builder to the previous snapshot.

validate(validation_level: ValidationLevel = ValidationLevel.SEMANTIC) list[ValidationIssue][source]

Run validation and return every detected issue.

validation_level() ValidationLevel | None[source]

Return the validation level currently configured on the controller.

property dirty: bool

Expose whether the controller currently tracks unsaved changes.

mafw.steering_gui.controllers.steering_controller.build_database_connection_configuration(config: Mapping[str, Any]) dict[str, Any][source]

Return a normalized configuration dict for connection checks.

The returned dictionary always contains URL plus backend-specific keys derived from extract_protocol.

mafw.steering_gui.controllers.steering_controller.recorded_mutation(method: Callable[[Concatenate[SteeringController, P]], R]) Callable[[Concatenate[SteeringController, P]], R][source]

Decorator that records the controller state before mutating operations.

mafw.steering_gui.controllers.steering_controller.P = ~P

Type variable capturing the positional parameters of the wrapped method.