populse_mia.user_interface.pipeline_manager.node_controller¶
Pipeline Node Management and Filtering Module
This module provides a collection of Qt-based widgets and controllers for managing pipeline nodes, filtering database entries, and assigning values to node plugs in a data processing workflow. It is designed to integrate with a pipeline editor, enabling users to:
View and edit node parameters, including inputs, outputs, and attributes.
Filter and select database entries (e.g., scans, files) for assignment to pipeline nodes.
Apply advanced search and tag-based filtering to refine selections.
Handle undo/redo operations for parameter changes and node renaming.
Manage subprocesses and context names for hierarchical pipelines.
The module is built on top of Qt and Capsul, leveraging custom widgets like AttributedProcessWidget and TableDataBrowser to provide a user-friendly interface for complex pipeline interactions.
Classes
|
A specialized widget for filtering database entries and collecting their attributes. |
|
A PyQt widget for managing and editing pipeline node parameters using Capsul's AttributedProcessWidget. |
|
A PyQt widget for filtering and selecting files in a pipeline's Input_Filter process. |
|
A PyQt widget for managing and editing the input/output values and parameters of a pipeline node. |
- class populse_mia.user_interface.pipeline_manager.node_controller.AttributesFilter(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Bases:
PlugFilterA specialized widget for filtering database entries and collecting their attributes.
This widget extends PlugFilter to provide a user-friendly interface for filtering files using both rapid and advanced search tools. It allows users to:
Filter database entries based on customizable criteria.
Select specific rows or use the entire filtered dataset.
Collect attributes from the selected or filtered entries.
Emit the collected attributes as a structured dictionary for further processing.
The collected attributes are organized into a dictionary where each key represents an attribute name, and the corresponding value is a list of all values for that attribute across the selected or filtered entries.
Contains:
Methods:
ok_clicked: Closes the widget and emits the collected attributes. If rows are selected, only those rows’ attributes are collected; otherwise, attributes are collected from all entries matching the current filter.
Signals:
attributes_selected: Signal emitted when the user validates the selection.
- ok_clicked()[source]¶
Close the widget and emit the collected attributes.
If rows are selected in the table, attributes are collected only from those rows. Otherwise, attributes are collected from all entries matching the current filter. The resulting attributes are grouped by field name and emitted via the
attributes_selectedsignal.
- class populse_mia.user_interface.pipeline_manager.node_controller.CapsulNodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidgetA PyQt widget for managing and editing pipeline node parameters using Capsul’s AttributedProcessWidget.
This controller provides a user interface for interacting with pipeline nodes, enabling users to:
View and modify node parameters using Capsul’s AttributedProcessWidget.
Rename nodes and update the pipeline accordingly.
Filter and manage node attributes.
Handle undo/redo operations for parameter changes.
Recursively rename subprocesses and adjust context names.
The widget is designed to integrate with a pipeline editor, providing real-time updates and synchronization between the UI and the underlying pipeline state.
Contains:
Methods:
display_parameters: Displays the parameters of the selected node and configures the UI.
filter_attributes: Opens a dialog for filtering node attributes.
release_process: Cleans up process notifications and signals.
rename_subprocesses: Recursively renames subprocesses and updates context names.
static_release: Removes trait change notifications from a process.
parameters_changed: Handles parameter value changes and emits a signal.
update_attributes_from_filter: Applies selected attributes from the filter widget.
update_node_name: Renames the selected node and updates the pipeline.
update_parameters: Placeholder for backward compatibility (no operation).
Signals:
value_changed: Signal emitted when a node or parameter value is changed.
- __init__(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Initialize the node controller.
- Parameters:
project – Current project instance.
scan_list – List of available scans.
pipeline_manager_tab – Parent pipeline manager tab.
main_window – Main application window.
- display_parameters(node_name, process, pipeline)[source]¶
Display the parameters of the selected node.
Creates and displays widgets for all node parameters, including line edits, labels, and control buttons. Handles special cases for pipeline inputs/outputs nodes.
- Parameters:
node_name – (str) Name of the node to display.
process – Process instance associated with the node.
pipeline – Current pipeline containing the node.
- filter_attributes()[source]¶
Display the attributes filter dialog.
Opens a popup widget that allows users to filter and select attributes for the current process node.
- rename_subprocesses(node, parent_node_name)[source]¶
Recursively rename subprocesses within the pipeline, adjusting the context name.
This method checks if the process is part of a pipeline and modifies its context name accordingly. If the process name contains a hierarchy of at least three levels, the context name is updated with the parent node name and the remaining parts of the context name. If the process is a pipeline node, the method is called recursively for each subprocess.
- Parameters:
node – The current node being processed.
parent_node_name – (str) The name of the parent node to be included in the context name.
- static static_release(process, param_changed)[source]¶
Remove trait change notification from process.
- Parameters:
process – Process instance to remove notification from.
param_changed – Callback function to remove.
- parameters_changed(_, plug_name, old_value, new_value)[source]¶
Handle parameter value changes and emit signal.
- Parameters:
_ – Unused parameter (object instance).
plug_name – (str) Name of the changed parameter.
old_value – Previous parameter value.
new_value – New parameter value.
- update_attributes_from_filter(attributes)[source]¶
Apply selected attributes from the filter widget.
Updates the process completion engine attributes based on user selection from the filter dialog. Shows a warning if no matching attributes are found.
- Parameters:
attributes – (dict) Dictionary of attribute names and values to apply.
- update_node_name(new_node_name=None, old_node_name=None, from_undo=False, from_redo=False)[source]¶
Change the name of the selected node and update the pipeline.
Renames the node in the pipeline dictionary and updates all associated links. For iterated processes, ensures the name starts with “iterated_”.
- Parameters:
new_node_name – (str) New name for the node. If None (when this method is not called from an undo/redo), reads from the line edit widget.
old_node_name – (str) Current node name. If None (when this method is not called from an undo/redo), uses self.node_name.
from_undo – (bool) True if this action is from an undo operation.
from_redo – (bool) True ifthis action is from a redo operation.
- class populse_mia.user_interface.pipeline_manager.node_controller.FilterWidget(project, node_name, node, main_window)[source]¶
Bases:
QWidgetA PyQt widget for filtering and selecting files in a pipeline’s Input_Filter process.
This widget provides a user-friendly interface for filtering database files using both rapid and advanced search functionalities. It allows users to:
Browse and select files from the project database.
Perform rapid searches using a text-based search bar.
Apply advanced filters using a customizable search interface.
Visualize and update tags associated with the files.
Save the configured filter to the process for further use in the pipeline.
The widget is designed to integrate seamlessly with the pipeline editor, providing real-time feedback and updates as filters are applied.
Contains:
Methods:
layout_view: Configures and initializes the main widget layout, including search bars, data tables, and action buttons.
normalize_scan_path: Normalize a scan path to a logical project-relative path.
ok_clicked: Applies the configured filter to the process and closes the widget.
reset_search_bar: Resets the search interface to its default state, clearing all filters.
search_str: Filters and updates the displayed scans based on the provided search string.
update_tag_to_filter: Opens a dialog for selecting tags to filter and updates the filter button text.
update_tags: Updates the list of visualized tags through a user dialog and refreshes the table view.
- __init__(project, node_name, node, main_window)[source]¶
Initialize the Filter Widget for pipeline node filtering.
- Parameters:
project – Current project instance containing database and configuration.
node_name – Display name of the filter node.
node – Input_Filter node instance containing the filter process.
main_window – Parent main window for UI hierarchy.
- layout_view()[source]¶
Configure and initialize the main widget layout.
- Sets up a vertical layout containing:
Search bar with reset button
Advanced search widget
Data table
Action buttons (visualize tags, filter, OK, Cancel)
The window is sized to 60% width and 80% height of the screen resolution.
- normalize_scan_path(scan_path)[source]¶
Normalize a scan path to a logical project-relative path.
Converts any scan path (absolute, relative, or symlinked) into a consistent project-relative representation, preferably starting at the project’s data directory.
- Resolution strategy (in order of preference):
Path relative to project root (if path is under project).
Path relative to ‘data/’ directory (semantic anchor fallback).
Absolute path string (last resort).
- Parameters:
scan_path – File path to normalize (absolute or relative).
- Returns:
Normalized path string, relative to project root when possible.
Examples
>>> normalize_scan_path('/abs/path/project/data/scans/001.tif') 'data/scans/001.tif' >>> normalize_scan_path('../other/data/scans/002.tif') 'data/scans/002.tif'
Note
Handles symlinks, mount aliases, and varying working directories robustly. Does not require paths to exist on disk.
- ok_clicked()[source]¶
Apply the configured filter to the process and close the dialog.
Collects filter parameters from the advanced search interface and rapid search text field, creates a Filter object, and applies it to the process if it’s a ProcessMIA instance. The dialog is then closed regardless of process type.
- reset_search_bar()[source]¶
Reset search interface to default state.
Clears the rapid search text field, resets advanced search rows, and restores the table to display all available scans. The table is updated efficiently by tracking the previous visualization state.
- Side effects:
Clears rapid_search text field.
Resets advanced_search rows to empty list.
Updates advanced_search display.
Restores table_data to show all scans from scan_list.
- search_str(str_search)[source]¶
Filter and update the displayed scans based on a search string.
Performs a rapid search to filter scans in the browser view. An empty search string displays all available scans. Special handling is provided for undefined values and custom search filters.
- Parameters:
str_search – Search query string. Use empty string to show all scans, or NOT_DEFINED_VALUE constant to filter scans with undefined fields.
- Side Effects:
Updates self.table_data.scans_to_visualize with filtered results.
Updates self.advanced_search.scans_list with filtered results.
Triggers table row update via self.table_data.update_visualized_rows().
- update_tag_to_filter()[source]¶
Display a tag selection dialog and update the filter button text.
Opens a popup dialog allowing the user to select from visible project tags. If a tag is selected (dialog accepted), updates the filter button’s text to reflect the chosen tag.
- update_tags()[source]¶
Update the list of visualized tags through a user dialog.
Opens a modal dialog that allows users to select which tags should be displayed in the table view. Upon confirmation, the method:
Updates table columns to show only selected tags
Refreshes advanced search field options
Ensures TAG_FILENAME is always included in visible tags
The dialog is automatically cleaned up after use, whether the user confirms or cancels the operation.
- class populse_mia.user_interface.pipeline_manager.node_controller.NodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidgetA PyQt widget for managing and editing the input/output values and parameters of a pipeline node.
This controller provides a user interface to interact with pipeline nodes, allowing users to:
View and edit node names and parameters.
Filter and update plug values.
Handle undo/redo operations for parameter changes.
Manage subprocesses and context names.
The widget is designed to integrate with a pipeline editor, providing real-time updates and synchronization between the UI and the underlying pipeline state.
Contains:
Methods:
clearLayout: Clears and deletes all items from a widget’s layout, including nested layouts.
display_filter: Displays a filter dialog for a plug.
display_parameters: Renders the parameters UI for a selected node.
get_index_from_plug_name: Returns the index of a plug label in the UI.
update_node_name: Updates the name of the selected node in the pipeline.
rename_subprocesses: Recursively updates context names for subprocesses.
update_parameters: Synchronizes UI parameter values with the process traits.
update_plug_value: Updates a plug value.
update_plug_value_from_filter: Updates a plug value from filter results.
release_process: Placeholder for process release logic (to be overridden by subclasses).
Signals:
value_changed: Signal emitted when a node or parameter value is changed.
- __init__(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Initialize the node controller widget.
This controller manages the interaction between the current project, the selected scans, and the active pipeline within the pipeline manager interface.
- Parameters:
project – The current project instance.
scan_list – The list of selected database files (scans).
pipeline_manager_tab – The parent pipeline manager tab widget.
main_window – The main application window.
- clearLayout(widget)[source]¶
Remove and delete all items from a widget’s layout.
- This method recursively clears the layout attached to the given widget:
QWidget items are detached from their parent.
Nested layouts are emptied and scheduled for deletion.
The layout itself is deleted once cleared.
- Parameters:
widget – (QtWidgets.QWidget) The widget whose layout should be cleared.
- display_filter(node_name, plug_name, parameters, process)[source]¶
Display an interactive filter widget for modifying plug values.
Creates and shows a PlugFilter dialog that allows users to filter and modify the value of a specific plug. The dialog’s value changes are automatically propagated back to update the plug through a signal connection.
- Parameters:
node_name – The name of the pipeline node containing the plug.
plug_name – The name of the plug to filter.
parameters – A three-element tuple (plug_index, pipeline_instance, plug_value_type) that provides the context of the plug currently being filtered.
process – The process instance associated with the node.
Note
The created PlugFilter is stored in self.pop_up and remains accessible until another filter is displayed or the instance is destroyed.
- display_parameters(node_name, process, pipeline)[source]¶
Display and configure parameters for the selected pipeline node.
Creates an interactive interface showing the node’s input and output parameters with editable fields. For pipeline global inputs (except ‘database_scans’), adds filter buttons for File/List_File/Any trait types.
- Special handling:
‘inputs’/’outputs’ nodes: Name field is read-only, displays “Pipeline inputs/outputs”.
Other nodes: Name field is editable and updates on Enter.
Parameters with userlevel > 0 are hidden from the interface.
- Parameters:
node_name – Identifier for the node being displayed.
process – Node’s process object containing traits and their values.
pipeline – Parent pipeline instance containing this node.
- Side effects:
Clears and rebuilds the widget layout.
Updates node_parameters_tmp in the current pipeline editor.
Enables the run_pipeline_action.
- get_index_from_plug_name(plug_name, in_or_out)[source]¶
Get the index of a plug by its name.
- Parameters:
plug_name – (str) The name of the plug to find.
in_or_out – (str) Direction of the plug ; “in” for input, “out” for output.
- Returns:
The zero-based index of the plug if found, None otherwise.
- update_node_name(new_node_name=None)[source]¶
Update the name of the currently selected node in the pipeline.
Renames a node in the pipeline dictionary, preserving all its properties and connections. If the pipeline contains a ProcessIteration, ensures the name is prefixed with ‘iterated_’.
- Parameters:
new_node_name – The new name for the node. If None, retrieves the name from the UI line edit widget. Is not None only when this method is called from an “undo/redo”)
- Emits value_changed:
Signal with node rename details for undo/redo tracking.
Note
Does nothing if the new name already exists in the pipeline.
- rename_subprocesses(node, parent_node_name)[source]¶
Recursively update context names for a node and its subprocesses.
This method updates the context_name attribute throughout a node hierarchy, ensuring consistent naming based on the parent context. For pipeline processes, it preserves the hierarchical structure while incorporating the parent node name.
- The context name follows these rules:
Pipeline processes: “Pipeline.{parent_node_name}.{additional_parts}”.
Non-pipeline processes: “{parent_node_name}”.
Nested subprocesses are updated recursively.
- Parameters:
node – (Node) The node whose context name will be updated, along with all its subprocesses.
parent_node_name – (str) The parent node’s name to incorporate into the context naming hierarchy.
- update_parameters(process=None)[source]¶
Update parameter values in the UI from the process traits.
Synchronizes input and output line edit widgets with the current values of the process traits. If no process is provided, uses the current process if available. The ‘nodes_activation’ trait is ignored. Undefined trait values are handled gracefully.
- Parameters:
process – Optional process node whose parameters should be displayed. If None, uses self.current_process.
- update_plug_value(in_or_out, plug_name, pipeline, value_type, new_value=None)[source]¶
Update the value of a node plug and propagate changes through the pipeline.
The new value is either explicitly provided (typically during undo/redo) or read from the corresponding line edit widget and evaluated. If the update fails, the previous value is restored in the UI and a warning dialog is shown.
- Parameters:
in_or_out – (str) Direction of the plug - “in” for input plugs, “out” for output plugs.
plug_name – (str) Name of the plug to update.
pipeline – The current pipeline instance.
value_type – (type) Expected type of the plug value.
new_value – (optional) New value for the plug. If None, reads from the line edit widget (is None except when this method is called from an “undo/redo”).
- Side Effects:
Updates the plug value in the pipeline node.
Updates the corresponding line edit widget text.
Triggers pipeline node and plug activation updates.
Emits value_changed signal for undo/redo tracking.
Displays status message in the main window.
Shows error dialog on TraitError or OSError.
Note
The method uses eval() to parse string input, which handles lists, dicts, and other Python literals. Special handling is included for ‘<undefined>’ values in dictionaries, which are converted to Undefined objects.
- update_plug_value_from_filter(plug_name, parameters, filter_res_list)[source]¶
Update a plug’s value based on filtered results.
Automatically unwraps single-item lists for convenience, setting the plug value to the item itself rather than a list containing one item.
- Parameters:
plug_name – Name of the plug to update.
parameters – Tuple (plug_index, pipeline_instance, value_type).
filter_res_list – Filtered file list to set as the plug value.
Note
Empty lists are preserved as empty lists
Single-item lists are unwrapped to the item itself
Multi-item lists are kept as lists