populse_mia.user_interface.pipeline_manager package¶
Handle the pipeline manager tab. Allow to create and run pipelines.
- Contains:
- Module:
iteration_table
node_controller
pipeline_editor
pipeline_manager_tab
process_library
process_mia
type_editors
Submodules¶
populse_mia.user_interface.pipeline_manager.iteration_table module¶
Module that handles pipeline iteration.
- Contains:
- Class:
IterationTable
- class populse_mia.user_interface.pipeline_manager.iteration_table.IterationTable(project, scan_list=None, main_window=None)[source]¶
Bases:
QWidget
Widget that handles pipeline iteration.
This widget allows users to select tags for iteration and visualization, filter values, and manage the iteration process for pipeline execution.
- __init__(project, scan_list=None, main_window=None)[source]¶
Initialize the IterationTable widget.
- Parameters:
project – Current project in the software.
scan_list – List of the selected database files. If None, all documents from the current collection will be used.
main_window – Software’s main window reference.
- fill_values(idx)[source]¶
Fill values_list with unique tag values for the specified tag.
- Parameters:
(int) (idx) – Index of the tag in push_buttons list.
- iteration_table_updated¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- refresh_layout()[source]¶
Update the layout of the widget.
Called in widget’s initialization and when a tag push button is added or removed.
- select_visualized_tag(idx)[source]¶
Open a dialog to select which tag to visualize in the iteration table.
- Parameters:
(int) (idx) – Index of the clicked push button.
- update_iterated_tag(tag_name=None)[source]¶
Update the widget when the iterated tag is modified.
- Parameters:
(str) (tag_name) – Name of the iterated tag.
- update_selected_tag(selected_tag)[source]¶
Update the lists of values corresponding to the selected tag.
Retrieves all unique values of the selected tag from scans in the current collection that also exist in the scan list. Then updates the tag value lists in the current pipeline editor.
- Parameters:
(str) (selected_tag) – The tag whose values should be retrieved and updated.
populse_mia.user_interface.pipeline_manager.node_controller module¶
Module to handle the node of a pipeline and its plugs.
- Contains:
- Class:
PlugFilter (must be declared before AttributesFilter)
AttributesFilter
CapsulNodeController
FilterWidget
NodeController
- class populse_mia.user_interface.pipeline_manager.node_controller.AttributesFilter(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Bases:
PlugFilter
Filter widget used on an attributes set for completion.
The widget displays a browser with the selected files of the database, a rapid search and an advanced search to filter these files. Once the filtering is done, the result (as a list of files) is set to the plug.
- attributes_selected¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- class populse_mia.user_interface.pipeline_manager.node_controller.CapsulNodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidget
Implementation of NodeController using Capsul AttributedProcessWidget widget.
- display_parameters(node_name, process, pipeline)[source]¶
Display the parameters of the selected node.
The node parameters are read and line labels/line edits/push buttons are created for each of them. This methods consists mainly in widget and layout organization.
- Parameters:
node_name – name of the node
process – process of the node
pipeline – current pipeline
- 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.
(str) (parent_node_name) – The name of the parent node to be included in the context name.
- 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 updates the pipeline.
Because the nodes are stored in a dictionary, we have to create a new node that has the same traits as the selected one and create new links that are the same than the selected node.
- Parameters:
(str) (old_node_name) – New node name (is None except when this method is called from an undo/redo).
(str) – Old node name (is None except when this method is called from an undo/redo).
(bool) (from_redo) – True if the action has been made using an undo.
(bool) – True if the action has been made using a redo.
- update_parameters(process=None)[source]¶
Update the parameters values.
Does nothing any longer since the controller widget already reacts to changes in the process parameters.
- Parameters:
process – Process of the node.
- value_changed¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- class populse_mia.user_interface.pipeline_manager.node_controller.FilterWidget(project, node_name, node, main_window)[source]¶
Bases:
QWidget
Filter widget used on a Input_Filter process.
The widget displays a browser with the selected files of the database, a rapid search and an advanced search to filter these files. Once the filtering is done, the filter is saved in the process.
- __init__(project, node_name, node, main_window)[source]¶
Initialization of the Filter Widget.
- Parameters:
project – current project in the software
node_name – name of the current node
node – instance of the corresponding Input_Filter node
main_window – parent main window
- class populse_mia.user_interface.pipeline_manager.node_controller.NodeController(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Bases:
QWidget
Allow to change the input and output values of a pipeline node
- __init__(project, scan_list, pipeline_manager_tab, main_window)[source]¶
Initialization of the Node Controller
- Parameters:
project – current project in the software
scan_list – list of the selected database files
pipeline_manager_tab – parent widget
main_window – main window of the software
- clearLayout(layout)[source]¶
Clear the layouts of the widget.
- Parameters:
layout – widget with a layout
- display_filter(node_name, plug_name, parameters, process)[source]¶
Display a filter widget.
- Parameters:
node_name – name of the node
plug_name – name of the plug
parameters – tuple containing the index of the plug, the current pipeline instance and the type of the plug value
process – process of the node
- display_parameters(node_name, process, pipeline)[source]¶
Display the parameters of the selected node.
The node parameters are read and line labels/line edits/push buttons are created for each of them. This methods consists mainly in widget and layout organization.
- Parameters:
node_name – name of the node
process – process of the node
pipeline – current pipeline
- get_index_from_plug_name(plug_name, in_or_out)[source]¶
Return the index of the plug label.
- Parameters:
plug_name – name of the plug
in_or_out – “in” if the plug is an input plug, “out” else
- Returns:
the corresponding index
- rename_subprocesses(node, parent_node_name)[source]¶
Change the name of a node and its subprocesses recursively.
This method updates the context_name attribute of a node and its subprocesses, adjusting the naming scheme based on the parent node’s name. If the node’s process is part of a pipeline, it will append the parent node’s name to the context name, preserving any additional parts of the original context name. The recursion ensures that all subprocesses within the given node are renamed accordingly.
Parameters¶
- nodeNode
The node whose context_name is to be renamed.
- parent_node_namestr
The name of the parent node to be used as part of the new context_name.
- update_node_name(new_node_name=None)[source]¶
Change the name of the selected node and updates the pipeline.
Because the nodes are stored in a dictionary, we have to create a new node that has the same traits as the selected one and create new links that are the same than the selected node.
- Parameters:
new_node_name – new node name (is None except when this method is called from an undo/redo)
- update_parameters(process=None)[source]¶
Update the parameters values.
- Parameters:
process – process of the node
- update_plug_value(in_or_out, plug_name, pipeline, value_type, new_value=None)[source]¶
Update the value of a node plug.
- Parameters:
in_or_out – “in” if the plug is an input plug, “out” else
plug_name – name of the plug
pipeline – current pipeline
value_type – type of the plug value
new_value – new value for the plug (is None except when this method is called from an undo/redo)
- update_plug_value_from_filter(plug_name, parameters, filter_res_list)[source]¶
Update the plug value from a filter result.
- Parameters:
plug_name – name of the plug
parameters – tuple containing the index of the plug, the current pipeline instance and the type of the plug value
filter_res_list – list of the filtered files
- value_changed¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- class populse_mia.user_interface.pipeline_manager.node_controller.PlugFilter(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Bases:
QWidget
Filter widget used on a node plug.
The widget displays a browser with the selected files of the database, a rapid search and an advanced search to filter these files. Once the filtering is done, the result (as a list of files) is set to the plug.
- __init__(project, scans_list, process, node_name, plug_name, node_controller, main_window)[source]¶
Initialization of the PlugFilter widget
- Parameters:
project – current project in the software
scans_list – list of database files to filter
process – process instance of the selected node
node_name – name of the current node
plug_name – name of the selected node plug
node_controller – parent node controller
main_window – parent main window
- plug_value_changed¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- populse_mia.user_interface.pipeline_manager.node_controller.values(d)[source]¶
Return a list of all values in the dictionary.
In Python 3, dict.values() returns a view, which is then converted to a list. This function ensures compatibility across Python versions by returning a list of the dictionary’s values.
- Args:
d (dict): The dictionary from which to retrieve values.
- Returns:
list: A list of values in the dictionary.
populse_mia.user_interface.pipeline_manager.pipeline_editor module¶
Module that execute the pipeline manager tab menu actions and allow to edit graphically a pipeline.
- Contains:
- Class:
PipelineEditor
PipelineEditorTabs
- Function:
save_pipeline
get_path
find_filename
values
- class populse_mia.user_interface.pipeline_manager.pipeline_editor.PipelineEditor(project, main_window)[source]¶
Bases:
PipelineDeveloperView
View to edit a pipeline graphically.
- __init__(project, main_window)[source]¶
Initialization of the PipelineEditor.
- Parameters:
project – current project in the software
main_window – current main window
- add_link(source, dest, active, weak, from_undo=False, from_redo=False, allow_export=False)[source]¶
Add a link between two nodes.
- Parameters:
source – tuple containing the node and plug source names
dest – tuple containing the node and plug destination names
active – boolean that is True if the link is activated
weak – boolean that is True if the link is weak
from_undo – boolean that is True if the action has been made using an undo
from_redo – boolean that is True if the action has been made using a redo
- add_named_process(class_process, node_name=None, from_undo=False, from_redo=False, links=[])[source]¶
Add a process to the pipeline.
- Parameters:
class_process – process class’s name (str)
node_name – name of the corresponding node (using when undo/redo) (str)
from_undo – boolean that is True if the action has been made using an undo
from_redo – boolean that is True if the action has been made using a redo
links – list of links (using when undo/redo)
- del_node(node_name=None, from_undo=False, from_redo=False)[source]¶
Delete a node.
- Parameters:
node_name – name of the corresponding node (using when undo/redo)
from_undo – boolean, True if the action has been made using an undo
from_redo – boolean, True if the action has been made using a redo
- export_node_plugs(node_name, inputs=True, outputs=True, optional=False, from_undo=False, from_redo=False)[source]¶
Export all the plugs of a node
- Parameters:
node_name – node name
inputs – True if the inputs have to be exported
outputs – True if the outputs have to be exported
optional – True if the optional plugs have to be exported
from_undo – True if this method is called from an undo action
from_redo – True if this method is called from a redo action
- get_current_filename()[source]¶
Return the relative path the pipeline was last saved to. Empty if never saved.
- Returns:
the current pipeline file name
- pipeline_modified¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- pipeline_saved¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- save_pipeline(filename=None)[source]¶
Save the pipeline.
- Returns:
the name of the file where the pipeline was saved
- update_history(history_maker, from_undo, from_redo)[source]¶
Update the history for undos and redos. This method is called after each action in the PipelineEditor.
- Parameters:
history_maker – list that contains information about what has been done
from_undo – boolean that is True if the action has been made using an undo
from_redo – boolean that is True if the action has been made using a redo
- update_node_name(old_node, old_node_name, new_node_name, from_undo=False, from_redo=False)[source]¶
Update a node name.
- Parameters:
old_node – Node object to change
old_node_name – original name of the node (str)
new_node_name – new name of the node (str)
from_undo – boolean, True if the action has been made using an undo
from_redo – boolean, True if the action has been made using a redo
- update_plug_value(node_name, new_value, plug_name, value_type, from_undo=False, from_redo=False)[source]¶
Update a plug value.
- Parameters:
node_name – name of the node (str)
new_value – new value to set to the plug
plug_name – name of the plug to change (str)
value_type – type of the new value
from_undo – boolean, True if the action has been made using an undo
from_redo – boolean, True if the action has been made using a redo
- class populse_mia.user_interface.pipeline_manager.pipeline_editor.PipelineEditorTabs(project, scan_list, main_window)[source]¶
Bases:
QTabWidget
Tab widget that contains pipeline editors.
- __init__(project, scan_list, main_window)[source]¶
Initialization of the Pipeline Editor tabs.
- Parameters:
project – current project in the software
scan_list – list of the selected database files
main_window – main window of the software
- check_modifications(current_index)[source]¶
Check if the nodes of the current pipeline have been modified.
- Parameters:
current_index – index to check
- close_tab(idx)[source]¶
Close the selected tab and editor.
- Parameters:
idx – index of the tab to close
- emit_node_clicked(node_name, process)[source]¶
Emit a signal when a node is clicked.
- Parameters:
node_name – node name
process – process of the corresponding node
- emit_pipeline_saved(filename)[source]¶
Emit a signal when a pipeline is saved.
- Parameters:
filename – file name of the pipeline
- emit_switch_clicked(node_name, switch)[source]¶
Emit a signal when a switch is clicked.
- Parameters:
node_name – node name
switch – process of the corresponding node
- export_to_db_scans(node_name)[source]¶
Export the input of a filter to “database_scans” plug.
- Parameters:
node_name – the name of the node from which to export
- get_capsul_engine()[source]¶
Get a CapsulEngine object from the edited pipeline, and set it up from MIA config object
- get_current_filename()[source]¶
Get the relative path to the file the pipeline in the current editor has been last saved to. If the pipeline has never been saved, returns the title of the tab.
- Returns:
the filename of the current editor
- get_current_pipeline()[source]¶
Get the instance of the current pipeline.
- Returns:
the pipeline of the current editor
- get_current_tab_name()[source]¶
Get the tab name of the editor in the current tab.
Trailing “*” and ampersand (”&”) characters are removed.
- Returns:
the current tab name
- get_editor_by_file_name(file_name)[source]¶
Get the instance of an editor from its file name.
- Parameters:
file_name – name of the file the pipeline was last saved to
- Returns:
the editor corresponding to the file name
- get_editor_by_index(idx)[source]¶
Get the instance of an editor from its index in the editors.
- Parameters:
idx – index of the editor
- Returns:
the editor corresponding to the index
- get_editor_by_tab_name(tab_name)[source]¶
Get the instance of an editor from its tab name.
- Parameters:
tab_name – name of the tab
- Returns:
the editor corresponding to the tab name
- get_filename_by_index(idx)[source]¶
Get the relative path to the file the pipeline in the editor at the given index has been last saved to. If the pipeline has never been saved, returns the title of the tab.
- Parameters:
idx – index of the editor
- Returns:
the file name corresponding to the index
- get_index_by_editor(editor)[source]¶
Get the index of the editor corresponding to the given editor.
- Parameters:
editor – searched pipeline editor
- Returns:
the index corresponding to the editor
- get_index_by_filename(filename)[source]¶
Get the index of the first editor corresponding to the given pipeline filename.
- Parameters:
filename – filename of the searched pipeline
- Returns:
the index corresponding to the file name
- get_index_by_tab_name(tab_name)[source]¶
Get the index of the editor corresponding to the given tab name.
- Parameters:
tab_name – name of the tab with the searched pipeline
- Returns:
the index corresponding to the tab name
- get_tab_name_by_index(idx)[source]¶
Get the tab name of the editor at the given index.
Trailing “*” and ampersand (”&”) characters are removed.
- Parameters:
idx – index of the editor
- Returns:
the tab name corresponding to the index
- has_pipeline_nodes()[source]¶
Check if any of the pipelines in the editor tabs have pipeline nodes.
- Returns:
True or False depending on if there are nodes in the editors
- load_pipeline(filename=None)[source]¶
Load a new pipeline.
- Parameters:
filename – not None only when this method is called from “open_sub_pipeline”
- node_clicked¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- open_filter(node_name)[source]¶
Open a filter widget.
- Parameters:
node_name – name of the corresponding node
- open_sub_pipeline(sub_pipeline)[source]¶
Open a sub-pipeline in a new tab.
- Parameters:
sub_pipeline – the pipeline to open
- pipeline_saved¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- process_clicked¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- set_current_editor_by_editor(editor)[source]¶
Set the current editor.
- Parameters:
editor – editor in the tab that should be made current
- set_current_editor_by_file_name(file_name)[source]¶
Set the current editor from file name.
- Parameters:
file_name – name of the file the pipeline was last saved to
- set_current_editor_by_tab_name(tab_name)[source]¶
Set the current editor from tab name.
- Parameters:
tab_name – name of the tab
- set_tab_index(index)[source]¶
Set the current tab index and disable the run pipeline action.
- Parameters:
index – index of the editor
- switch_clicked¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- populse_mia.user_interface.pipeline_manager.pipeline_editor.find_filename(paths_list, packages_list, file_name)[source]¶
Find the corresponding file name in the paths list of process_config.yml.
- Parameters:
paths_list – list of all the paths contained in process_config.yml
packages_list – packages path
file_name – name of the sub-pipeline
- Returns:
name of the corresponding file if it is found, else None
- populse_mia.user_interface.pipeline_manager.pipeline_editor.get_path(name, dictionary, prev_paths=None, pckg=None)[source]¶
Return the package path to the selected sub-pipeline.
- Parameters:
name – name of the sub-pipeline
dictionary – package tree
prev_paths – paths of the last call of this function
pckg – package root
- Returns:
the package path of the sub-pipeline if it is found, else None
populse_mia.user_interface.pipeline_manager.pipeline_manager_tab module¶
Module to define pipeline manager tab appearance, settings and methods.
- Contains:
- Class:
PipelineManagerTab
RunProgress
RunWorker
StatusWidget
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.PipelineManagerTab(project, scan_list, main_window)[source]¶
Bases:
QWidget
Widget that handles the Pipeline Manager tab.
- __init__(project, scan_list, main_window)[source]¶
Initialization of the Pipeline Manager tab
- Parameters:
project – current project in the software
scan_list – list of the selected database files
main_window – main window of the software
- add_plug_value_to_database(p_value, brick_id, history_id, node_name, plug_name, full_name, job, trait, inputs, attributes)[source]¶
Add the plug value to the database.
- Parameters:
p_value – plug value, a file name or a list of file names (any)
brick_id – brick uuid in the database (str)
history_id – history uuid in the database (str)
node_name – name of the node (str)
plug_name – name of the plug (str)
full_name – full name of the node, including parent brick(s) (str). If there is no parent brick, full_name = node_name.
job – job containing the plug (Job)
trait – handler of the plug trait, or sub-trait if the plug is a list (Trait). It will be used to check the value type (file or not).
inputs – input values for the process/node (dict)
attributes – attributes set coming from Capsul completion engine to be set on all outputs of the node (dict)
- ask_iterated_pipeline_plugs(pipeline)[source]¶
Opens a dialog to configure pipeline plugs for iteration or database connection.
This method displays a dialog allowing the user to specify which pipeline plugs should be iterated, not iterated, or connected to a database filter (input_filter node). The user can configure inputs and outputs of the pipeline, and the configuration is returned upon acceptance of the dialog.
- Args:
pipeline: The pipeline object whose plugs need to be configured.
- Returns:
- tuple:
- iterated_plugs (list): A list of plug names marked for
iteration.
- database_plugs (list): A list of plug names connected to
the database.
Returns None if the dialog is canceled by the user.
- build_iterated_pipeline()[source]¶
Build a new pipeline with an iteration node, iterating over the current pipeline
- check_requirements(environment='global')[source]¶
Check and return the configuration of a pipeline based on its requirements.
This method iterates through the nodes in the pipeline, gathers their requirements, and determines the appropriate configuration for each node in the specified environment. It uses the settings from the study configuration engine to select configurations that match the requirements.
- Args:
- environment (str, optional): The target environment for checking
configurations. Defaults to “global”.
- Returns:
- dict: A dictionary where the keys are pipeline nodes and the values
are the configurations selected for each node based on their requirements.
- complete_pipeline_parameters(pipeline=None)[source]¶
Automatically complete pipeline parameters using Capsul’s completion engine.
This method utilizes Capsul’s completion engine to automatically populate the parameters of a pipeline based on a set of attributes. These attributes can be retrieved from an associated database. If no pipeline is specified, the current pipeline or process is used.
- Args:
- pipeline (Pipeline, optional): The pipeline object to be completed.
If not provided, the method retrieves the current pipeline or process.
- controller_value_changed(signal_list)[source]¶
Update history when a pipeline node is changed
- Parameters:
signal_list – list of the needed parameters to update history. [“plug_value” or “node_name”, node_name, old_value, plug_name, plug_name_type, new_value]
- displayNodeParameters(node_name, process)[source]¶
Display the node controller when a node is clicked
- Parameters:
node_name – name of the node to display parameters
process – process instance of the corresponding node
- Returns:
- garbage_collect()[source]¶
Perform cleanup of obsolete data and database entries.
This method indexes finished brick executions, identifies and removes obsolete bricks and data, and performs postprocessing on the database to ensure it remains consistent and up-to-date. It also updates the user interface and the state of the pipeline editor.
- get_capsul_engine()[source]¶
Get a CapsulEngine object from the edited pipeline, and set it up from MIA config object
- get_pipeline_or_process(pipeline=None)[source]¶
Retrieve the input pipeline or its sole unconnected child process.
This method retrieves the pipeline currently being edited in the GUI or returns its single unconnected child process if applicable. This allows a single process node to be used as a pipeline for iteration or execution from the GUI.
- Args:
- pipeline (Pipeline, optional):
The pipeline to evaluate. If not provided, the method retrieves the currently selected pipeline from the editor GUI.
- Returns:
- Pipeline or Process:
If the pipeline has a single child process node that is not connected to other nodes, the child process is returned.
Otherwise, the input pipeline is returned.
- Behavior:
If pipeline is not specified, the currently selected pipeline pipeline editor is used.
If the pipeline contains only two nodes (the root node and one process node) and the root node has no plugs, the method returns the child process instead of the entire pipeline.
- Example Use Case:
This method is useful for scenarios where a single process node can act as a simplified pipeline, facilitating iterations or execution in a GUI-based workflow.
- init_pipeline(pipeline=None, pipeline_name='')[source]¶
Initialize the current pipeline of the pipeline editor
- Parameters:
pipeline – not None if this method call a sub-pipeline
pipeline_name – name of the parent pipeline
- item_library_clicked¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- postprocess_pipeline_execution(pipeline=None)[source]¶
Operations to be performed after a run has been completed.
It can be called either within the run procedure (the user clicks on the “run” button and waits for the results), or after a disconnetion / reconnection of the client app: the user clicks on “run” with distributed/remote execution activated, then closes the client MIA. Processing takes place (possibly remotely) within a soma-workflow server. Then the user runs MIA again, and we have to collect the outputs of runs which happened (finished) while we were disconnected.
Such post-processing includes database indexing of output data, and should take into account not only the current pipeline, but all past runs which have not been postprocessed yet.
When called with a pipeline argument, it only deals with this one.
The method can be called from within a worker run thread, thus has to be thread-safe.
- Args:
- pipeline (Pipeline, optional):
The pipeline to postprocess. If not provided, the method will use self.last_run_pipeline or fetch the currently selected pipeline from the pipeline editor.
Question 1: do we have to postprocess failed runs (pipelines which started and failed) ? Probably yes because they may have produced some results during the first steps, and failed later.
Question 2: how to decide which pipelines / runs have to be posptocessed now ? A pipeline may be started, then stopped or could have failed, then be postprocessed. But the user can still restart them in soma-workflow (or maybe mia one day), thus they should be postprocessed again then.
- redo()[source]¶
Redo the last undone action on the current pipeline editor
- Actions that can be redone:
add_process
delete_process
export_plug
export_plugs
remove_plug
update_node_name
update_plug_value
add_link
delete_link
- register_completion_attributes(pipeline)[source]¶
Register completion attributes for a given pipeline in the database.
This method extracts attribute values associated with a pipeline’s completion engine and records these attributes in the project database. It ensures that attributes are associated only with valid fields (tags) already defined in the database schema.
- Args:
- pipeline:
The pipeline whose completion attributes need to be registered. The pipeline should have a completion engine capable of providing the relevant attributes.
- remove_progress()[source]¶
Remove and clean up the progress widget.
This method ensures that the progress widget is properly cleaned up and deleted to free up resources. It performs the following steps:
Calls the cleanup method on the progress widget.
Closes the widget to remove it from view.
Deletes the widget later to free memory.
Deletes the reference to the progress widget from the instance.
- saveParameters()[source]¶
Save the pipeline parameters of the the current pipeline of the pipeline editor
- savePipeline(uncheck=False)[source]¶
Save the current pipeline of the pipeline editor
- Parameters:
uncheck – a flag to warn (False) or not (True) if a pipeline is going to be overwritten during saving operation
- undo()[source]¶
Undo the last action made on the current pipeline editor
- Actions that can be undone:
add_process
delete_process
export_plug
export_plugs
remove_plug
update_node_name
update_plug_value
add_link
delete_link
- updateProcessLibrary(filename)[source]¶
Update the library of processes when a pipeline is saved
- Parameters:
filename – file name of the pipeline that has been saved
- static update_auto_inheritance(node, job=None)[source]¶
Automatically infer database tags for output parameters from input parameters.
When a node has only one input with a value (filename) in the database, then output filenames are considered to inherit from it. When several input parameters have values in the database, then if they are all equal, we can fallback to the first case. When values are different, and have different database tags, then the ambiguity remains, and we keep track of the several possible inputs which can provide tags for outputs.
The process attribute auto_inheritance_dict is filled with these values. It’s a dict with the shape:
{output_filename: <input_spec>}
output_filename is the relative filename in the database
<input_spec> can be:
a string: filename
a dict:
{input_param: input_filename}
auto_inheritance_dict is built automatically, and is used as a fallback to
ProcessMIA
inheritance_dict, built “manually” (specialized for each process) in theProcessMIA.list_outputs()
when the latter does not exist, or does not specify what an output inherits from.If ambiguities still subsist, the MIA infrastructure will ask the user how to solve them, which is not very convenient, and error-prone, thus should be avoided.
- Args:
- node:
The node (typically a process or process node) whose inputs and outputs are analyzed for tag inheritance.
- job:
An optional job object containing parameter values to override or populate the node’s inputs and outputs. Defaults to None.
- update_inheritance(job, node)[source]¶
Update the inheritance dictionary for a process node in a pipeline execution.
This method updates the inheritance_dict attribute of a job based on the node’s context and the project’s inheritance history. It determines the metadata relationships between input and output parameters, which can then be used to propagate database tags and other properties.
- Args:
- job:
A job object that represents the execution of the process. It contains the param_dict attribute, which maps parameter names to their values.
- node:
The process node being evaluated. It can be a ProcessNode or a Process object and is used to identify the appropriate inheritance rules.
- update_node_list(brick=None)[source]¶
Update the list of nodes in the workflow by checking the jobs.
This method iterates over all jobs in the current workflow and updates the node_list with the associated nodes that have not been added previously. Each job is expected to have an associated process, and the corresponding node is added to the node_list if it is not already present.
- Args:
- brick (optional):
An optional parameter that is currently unused. It could be used for future extensions or to apply filters when selecting nodes.
- update_project(project)[source]¶
Update the project attribute of several objects.
- Parameters:
project – current project in the software.
- update_scans_list(iteration_list, all_iterations_list)[source]¶
Update the user-selected list of scans.
- Parameters:
iteration_list – current list of scans in the iteration table.
- update_user_buttons_states(index=-1)[source]¶
Update the visibility and enabled/disabled state of pipeline-related actions (such as “Run” and “Save”) based on the current state of the pipeline or editor.
This method checks the pipeline associated with the current or specified editor and updates the state of the UI buttons accordingly:
The “Run Pipeline” button is disabled if there are no processes in the pipeline.
The “Save Pipeline” and “Save Pipeline As” buttons are only
enabled if the pipeline is not marked as iterated.
- Args:
- index (int, optional): The index of the editor to check for a
pipeline. If not provided (default is -1), the current editor will be used.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.RunProgress(pipeline_manager, settings=None)[source]¶
Bases:
QWidget
Create and manage the progress bar for the pipeline execution. This class creates a UI with a progress bar and launches a worker thread to handle the pipeline’s execution process. The progress bar will be updated during the execution, and it will be closed when the thread finishes.
This class is designed to integrate with a PipelineManagerTab to control the pipeline’s lifecycle, providing feedback on the progress and handling any errors that occur during the execution.
- Attributes:
- pipeline_manager (PipelineManagerTab):
The pipeline manager instance that handles the pipeline operations.
- progressbar (QProgressBar):
The progress bar widget to show execution progress.
- worker (RunWorker):
The worker thread that runs the pipeline.
- Args:
- pipeline_manager (PipelineManagerTab):
A PipelineManagerTab instance responsible for managing the pipeline.
- settings (dict, optional):
A dictionary of settings to customize pipeline iteration, default is None.
- cleanup()[source]¶
Cleans up resources used by the RunProgress widget after the pipeline execution has finished.
This method stops the worker thread, disconnects the finished signal from the slot, and deletes the worker instance to free up resources. It ensures that the worker thread has completed its execution before proceeding with cleanup.
Optionally, it can also delete or hide UI components such as the progress bar, though these actions are currently commented out for flexibility.
If this method is called, the worker thread should no longer be used, and any UI elements related to progress should be cleaned up.
- end_progress()[source]¶
Finalizes the pipeline execution process and displays a message box indicating the outcome of the execution.
This method is called when the pipeline execution finishes. It restores the cursor, waits for the worker thread to complete, and then determines the status of the pipeline execution. A message box is displayed to inform the user about the success or failure of the execution.
If the execution fails before running, a critical message box will be shown. If the pipeline execution fails during its run, an error message with details will be shown. If the execution is successful, a success message will be displayed.
It also sets a timer to automatically close the message box after 2 seconds.
- start()[source]¶
Starts the worker thread to begin the pipeline execution process.
This method initiates the worker thread by calling its start method, which in turn triggers the execution of the pipeline. The progress bar could be updated to show the progress of the execution (though this functionality is currently commented out).
- stop_execution()[source]¶
Stops the execution of the pipeline by signaling the worker to interrupt.
This method sets the interrupt_request flag to True within the worker thread’s lock, which tells the worker to stop its execution. The method can be used to cancel the pipeline execution at any point during its run.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.RunWorker(pipeline_manager)[source]¶
Bases:
QThread
Worker thread to run the pipeline execution.
This class manages the execution of a pipeline and allows it to be run in the background using a separate thread. The worker can also be interrupted by setting the interrupt_request flag.
- Parameters:
pipeline_manager – The PipelineManager instance that manages the pipeline execution.
- class populse_mia.user_interface.pipeline_manager.pipeline_manager_tab.StatusWidget(pipeline_manager)[source]¶
Bases:
QWidget
A widget to display the current or last pipeline execution status and logs.
- This widget shows:
The current status of the pipeline (or “No pipeline execution” if not available).
A log of the most recent pipeline execution.
A toggleable section for Soma-Workflow monitoring.
- toggle_soma_workflow(checked)[source]¶
Toggles the visibility of the Soma-Workflow monitoring widget.
When enabled, the Soma-Workflow monitoring widget will be displayed below the status section. If it’s not yet created, it will be instantiated.
- Args:
- checked (bool): Whether the toggle box is checked (True) or
unchecked (False).
populse_mia.user_interface.pipeline_manager.process_library module¶
Module that contains class and methods to process the different libraries of the project.
- Contains:
- Class:
DictionaryTreeModel
InstallProcesses
Node
PackageLibrary
PackageLibraryDialog
ProcessHelp
ProcessLibrary
ProcessLibraryWidget
- Functions:
import_file
node_structure_from_dict
- class populse_mia.user_interface.pipeline_manager.process_library.DictionaryTreeModel(root, parent=None)[source]¶
Bases:
QAbstractItemModel
Data model providing a tree structure for an arbitrary dictionary.
This model is designed to represent a dictionary as a tree structure, enabling interaction with the data through a tree view.
- __init__(root, parent=None)[source]¶
Initializes the DictionaryTreeModel with a root node.
- Parameters:
root – The root node of the tree.
“param parent (QObject): The parent object.
- columnCount(parent=None)[source]¶
Returns the number of columns, which is always 1.
- Parameters:
(QModelIndex) (parent) – The parent index (unused in this implementation).
- Return (int):
The number of columns.
- data(index, role)[source]¶
Returns the data stored under the given role for the item at the given index.
- Parameters:
(QModelIndex) (index) – The index of the item.
(Qt.ItemDataRole) (role) – The role of the data to retrieve.
- Returns:
The data stored under the given role, or None if not available.
- flags(index)[source]¶
Get the item flags for the specified index.
- Parameters:
(QModelIndex) (index) – The model index to retrieve flags for.
- Return (Qt.ItemFlags):
The corresponding item flags.
- getNode(index)[source]¶
Retrieves the Node object from the given index.
- Parameters:
(QModelIndex) (index) – The index of the node.
- Returns:
The Node object.
- headerData(section, orientation, role)[source]¶
Returns the data for the given role and section in the header.
- Parameters:
(int) (section) – The section number.
(Qt.Orientation) (orientation) – The orientation of the header (unused in this implementation).
(Qt.ItemDataRole) (role) – The role of the data to retrieve.
- Return (str):
The header data, or None if not available.
- index(row, column, parent)[source]¶
Creates an index for the given row, column, and parent.
- Parameters:
(int) (column) – The row number.
(int) – The column number.
(QModelIndex) (parent) – The parent index.
- Return (QModelIndex):
The created index, or an invalid index if not available.
- insertRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]¶
Inserts rows starting from the specified position.
- Parameters:
(int) (rows) – The starting position to insert rows.
(int) – The number of rows to insert.
(QModelIndex) (parent) – The parent index.
- Return (bool):
True if the rows were successfully inserted, False otherwise.
- mimeData(indexes)[source]¶
Generate MIME data for a drag-and-drop operation.
- Parameters:
QModelIndex) (indexes (list of) – The list of model indexes being dragged.
- Return (QMimeData):
A QMimeData object containing serialized node information.
- mimeTypes()[source]¶
Returns the supported MIME types.
- Return (list of str):
A list of supported MIME types.
- parent(index)[source]¶
Returns the parent index for the given index.
- Parameters:
(QModelIndex) (index) – The index of the item.
- Return (QModelIndex):
The parent index, or an invalid index if not available.
- removeRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]¶
Removes rows starting from the specified position to position+rows.
- Parameters:
(int) (rows) – The starting position to remove rows.
(int) – The number of rows to remove.
(QModelIndex) (parent) – The parent index.
- Return (bool):
True if all rows were successfully removed, False otherwise.
- rowCount(parent)[source]¶
Returns the number of rows, which corresponds to the number of children.
- Parameters:
(QModelIndex) (parent) – The parent index.
- Return (int):
The number of rows.
- setData(index, value, role=2)[source]¶
Updates the data when the user makes changes.
- Parameters:
(QModelIndex) (index) – The index of the item.
value – The new value to set.
(Qt.ItemDataRole) (role) – The role of the data to set.
- Return (bool):
True if the data was successfully set, False otherwise.
- class populse_mia.user_interface.pipeline_manager.process_library.InstallProcesses(main_window, folder)[source]¶
Bases:
QDialog
Dialog for installing Python packages from a folder or zip file.
This widget allows users to browse and select a Python package or zip file containing packages, then install them into Populse_MIA.
- __init__(main_window, folder)[source]¶
Initialize the installation dialog.
- Parameters:
main_window – The main application window
(bool) (folder) – If True, install from folder; if False, install from zip file
- get_filename(folder)[source]¶
Open a file dialog to select the package source.
- Parameters:
(bool) (folder) – If True, opens a directory selection dialog; If False, opens a zip file selection dialog
- install()[source]¶
Install a package from a zip file or a folder.
This method handles the complete installation process: 1. Extracts or copies the package to the processes directory 2. Updates the process dictionary 3. Registers the new package in the configuration
Any exceptions during installation are caught and reported to the user, with automatic rollback of any changes made.
- process_installed¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- class populse_mia.user_interface.pipeline_manager.process_library.Node(name, parent=None)[source]¶
Bases:
object
A tree-like structure to manage hierarchical data with parent-child relationships.
This class provides functionality to create and manipulate tree nodes, where each node can have a name, value, parent, and multiple children.
- __init__(name, parent=None)[source]¶
Initialize a new Node instance.
- Parameters:
(str) (name) – The name of the node.
parent – The parent node. If provided, this node is automatically added as a child to the parent. Defaults to None.
- attrs()[source]¶
Get attributes of this node as a dictionary.
- Return (dict):
A dictionary of property names and their values.
- child(row)[source]¶
Get a child node by its index.
- Parameters:
(int) (row) – The index of the child node in the children list.
- Returns:
The child node at the specified index.
- childCount()[source]¶
Get the number of children of this node.
- Return (int):
The number of child nodes.
- data(column)[source]¶
Get data about this node based on the column parameter.
- Parameters:
(int) (column) – 0 for the fully qualified name (including parent names), 1 for the value of this node.
- Return (str):
The requested data (either string path or node value).
- insertChild(position, child)[source]¶
Insert a child node at a specific position.
- Parameters:
(int) (position) – The position at which to insert the child.
child – The child node to insert.
- Return (bool):
True if insertion was successful, False otherwise.
- log(tabLevel=-1)[source]¶
Generate a formatted string representation of the node hierarchy.
- Parameters:
(int) (tabLevel) – The current indentation level. Defaults to -1.
- Retur (str):
A formatted string showing the node hierarchy.
- property name¶
Get the name of this node.
- Return (str):
The name of the node.
- parent()[source]¶
Get the parent of this node.
- Returns:
The parent node or None if this is a root node.
- removeChild(position, child)[source]¶
Remove a child node at the specified position.
- Parameters:
(int) (position) – The position of the child to remove.
child – The child node to remove.
- Return (bool):
True if removal was successful, False otherwise.
- resource()[source]¶
Get resource information for this node.
This method is a placeholder that always returns None.
- Returns:
None
- row()[source]¶
Get the index of this node in its parent’s children list.
- Return (int):
The index of this node in its parent’s children list, or None if this node has no parent.
- setData(column, value)[source]¶
Set the name or value of this node based on the column parameter.
- Parameters:
(int) (column) – 0 to set the name, 1 to set the value.
value – The new name or value to set.
- to_dict(d=None)[source]¶
Convert the node hierarchy to a dictionary.
- Parameters:
(dict) (d) – A dictionary to populate. Defaults to empty dict.
- Return (dict):
A dictionary representation of the node hierarchy.
- to_list()[source]¶
Convert the node hierarchy to a list.
- Return (list):
A list representation of the node hierarchy.
- property value¶
Get the value of this node.
- Returns:
The value of the node.
- class populse_mia.user_interface.pipeline_manager.process_library.PackageLibrary(package_tree, paths)[source]¶
Bases:
QTreeWidget
A tree widget that displays user-added packages and their modules.
This widget allows users to enable or disable packages and modules by checking or unchecking them in the tree view. The tree structure reflects the hierarchical organization of packages and their modules.
- __init__(package_tree, paths)[source]¶
Initialize the PackageLibrary widget.
- Parameters:
(dict) (package_tree) – Hierarchical representation of packages.
(list) (paths) – System paths for importing the packages.
- fill_item(item, value)[source]¶
Recursively populate the tree items.
Traverses the package tree and creates corresponding QTreeWidgetItems with appropriate check states.
- generate_tree()[source]¶
Generate the package tree structure.
Clears the current tree and populates it with items from package_tree. Temporarily disconnects the itemChanged signal to prevent unwanted updates.
- recursive_checks(parent)[source]¶
Propagate check state down to all child items.
When a parent item is checked/unchecked, all its children inherit the same check state.
- Parameters:
(QTreeWidgetItem) (parent) – Parent item whose check state is propagated.
- recursive_checks_from_child(child)[source]¶
Propagate check state up to parent items.
When a child item is checked, its parents are also checked. When a child item is unchecked, its parent is unchecked only if all siblings are also unchecked.
- Parameters:
(QTreeWidgetItem) (child) – Child item whose check state affects parents.
- set_module_view(item, state)[source]¶
Update the module’s enabled/disabled status in the package tree.
Updates the underlying package_tree data structure when an item’s check state changes in the UI.
- Parameters:
(QTreeWidgetItem) (item) – Tree item corresponding to a module.
(Qt.CheckState) (state) – New check state, Qt.Checked or Qt.Unchecked. (Qt.Checked == 2. So if val == 2 -> checkbox is checked, and if val == 0 -> checkbox is not checked)
- update_checks(item, column)[source]¶
“Handle check state changes and propagate them.
When an item’s check state changes, this method ensures the change is properly propagated to children and parent items.
- Parameters:
(QTreeWidgetItem) (item) – Item whose check state changed.
(int) (column) – Column index of the change (should be 0).
- class populse_mia.user_interface.pipeline_manager.process_library.PackageLibraryDialog(mia_main_window=None, parent=None)[source]¶
Bases:
QDialog
Dialog for managing package library configurations.
This dialog allows users to add, remove, and delete packages from the process library. It provides interfaces for installing packages, updating the package tree, and saving configurations.
- __init__(mia_main_window=None, parent=None)[source]¶
Initialize the PackageLibraryDialog.
- Parameters:
mia_main_window – Reference to the main application window.
(QWidget) (parent) – Parent widget for the dialog.
- add_package(module_name, class_name=None, show_error=False, init_package_tree=False)[source]¶
Add a package and its modules to the package tree with comprehensive module and class discovery.
This method recursively discovers and adds packages, subpackages, and their classes to the package tree. It provides flexible options for package initialization and error handling.
- Parameters:
(str) (class_name) – Fully qualified name of the module to add. Example: ‘myproject.processors’
(str) – Specific class name to focus on during package addition. If provided, only this class or its parent packages will be processed.
(bool) (init_package_tree) – Controls error reporting behavior. If True, displays error messages in a QMessageBox. If False, collects errors silently. Defaults to False.
(bool) – If True, reinitializes the entire package tree before adding the module. Defaults to False.
- Return (List[str] | str):
A list of error messages encountered during package addition, or “No package selected!” if no module name is provided.
- add_package_with_text(package_name=False, update_view=True)[source]¶
Add a package to the Package Library.
This method attempts to add a package or module to the library based on the provided package name. It supports adding packages with or without file extensions, and handles various import scenarios.
- Parameters:
False) (package_name (str |) – Name of the package to add. If False (default), uses the text from the line edit widget.
(bool) (update_view) – Whether to update the package list view. Defaults to True.
- delete_package(index=1, to_delete=None, remove=True, loop=False, from_pipeline_manager=False)[source]¶
Delete a package from the library (admin-only functionality).
This method removes the package from the package library tree, updates the __init__.py file, and deletes the package directory and files if they are empty.
- Parameters:
(int) (index) – Recursive index for navigating modules. Defaults to 1.
(str) (to_delete) – The package/brick to delete (e.g., ‘test.Test’). Defaults to None.
(bool) (from_pipeline_manager) – Whether to remove the brick from the package tree. Defaults to True.
(bool) – Whether to delete silently without confirmation. Defaults to False.
(bool) – Whether deletion is initiated from pipeline manager. Defaults to False.
- Return (list[str]):
A list of deleted packages/bricks.(classes).
- delete_package_with_text(package_name='', update_view=True)[source]¶
Delete a package from the line edit’s text.
- Parameters:
(str) (package_name) – The name of the package to delete. Defaults to the text in the line edit.
(bool) (update_view) – Whether to update the QListWidget after deletion. Defaults to True.
- install_processes_pop_up(from_folder=False)[source]¶
Display the install processes pop-up.
- Parameters:
(bool) (from_folder) – Whether the installation is from a folder. Defaults to False.
- static load_config()[source]¶
Loads and returns the configuration from ‘process_config.yml’.
- Return (dict | {}):
The configuration dictionary if successfully loaded, otherwise None in case of an error.
- remove_package(package)[source]¶
Removes a package from the package tree.
This method attempts to remove the specified package from the package library. If the package is not found, a warning message is displayed. The package tree is updated after a successful removal.
- Parameters:
(str) (package) – The fully qualified module name (e.g., ‘nipype.interfaces.spm’).
- Returns (bool):
True if the package was successfully removed, False if the package was not found or no package was provided.
- remove_package_with_text(package_name='', update_view=True, tree_remove=True)[source]¶
Removes the specified package from the package tree and updates the view accordingly.
- Parameters:
(str) (package_name) – The name of the package to remove. If not provided, the package name is taken from the line edit.
(bool) (tree_remove) – Whether to update the QListWidget view after removal. Defaults to True.
(bool) – Whether to remove the package from the tree. Defaults to True.
- reset_action(itemlist, add)[source]¶
Resets a previous package addition or removal action.
- Parameters:
(QListWidget) (itemlist) – The list widget containing items to reset.
(bool) (add) – If True, resets an addition by removing the package if it exists in the configuration. If False, re-adds the package.
- save(close=True)[source]¶
Saves the package library configuration to process_config.yml.
This method updates the package information from the package library tree and writes it to the configuration file. Optionally, it can close the dialog after saving.
- Parameters:
(bool) (close) – If True, closes the dialog after saving. Defaults to True.
- signal_save¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibrary(d, pkg_lib)[source]¶
Bases:
QTreeView
A tree view to display available Capsul’s processes.
- Parameters:
d – dictionary corresponding to the tree (dict)
- __init__(d, pkg_lib)[source]¶
Initialize the ProcessLibrary class.
- Parameters:
(dict) (d) – Dictionary corresponding to the tree.
pkg_lib – An instance of the PackageLibraryDialog class.
- item_library_clicked¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- keyPressEvent(event)[source]¶
Handles key press events, specifically the Delete key.
If the Delete key is pressed and the user is not in user mode, the selected package(s) will be deleted from the package library.
- Parameters:
(QKeyEvent) (event) – The key event triggering this handler.
- load_dictionary(d)[source]¶
Load a dictionary into the tree.
- Parameters:
(dict) (d) – Dictionary to load. See the packages attribute in the ProcessLibraryWidget class.
- mousePressEvent(event)[source]¶
Handles mouse press events on the tree view.
If a valid item is clicked, it sets the current index and emits a signal with the selected item’s text. If the right mouse button is pressed, a context menu is displayed, allowing the user to remove or delete a package.
- Parameters:
(QMouseEvent) (event) – The mouse event triggering this handler.
- class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibraryWidget(main_window=None)[source]¶
Bases:
QWidget
Widget that manages the available Capsul’s processes in the software.
- __init__(main_window=None)[source]¶
Initialize the ProcessLibraryWidget.
- Parameters:
main_window – The current main window.
- populse_mia.user_interface.pipeline_manager.process_library.import_file(full_name, path)[source]¶
Import a Python module from a specified file path.
This function dynamically imports a module from a given file path and returns the module object. It does not modify sys.modules.
- Parameters:
(str) (path) – The name of the module to import.
(str) – The file path of the module.
- Returns:
The imported module.
- populse_mia.user_interface.pipeline_manager.process_library.node_structure_from_dict(datadict, parent=None, root_node=None)[source]¶
Construct a hierarchical node structure from a dictionary.
This function converts a nested dictionary into a tree structure suitable for a TreeModel. It processes nodes based on specific conditions and recursively builds the tree.
- Parameters:
(dict) (datadict) – The dictionary to convert into a node structure.
parent – The parent node of the current node. Defaults to None.
root_node – The root node of the tree. Defaults to None.
- Returns:
The root node of the constructed tree.
populse_mia.user_interface.pipeline_manager.process_mia module¶
Module for managing and running processes within the Populse_mia framework.
This module provides specialized classes and methods to handle the execution and completion of processes within the Populse_mia framework. It includes functionalities for managing process attributes, handling database interactions, and ensuring proper inheritance of metadata tags. The module supports various process types, including those from mia_processes, Nipype, and Capsul.
- Contains:
- Class:
MIAProcessCompletionEngine
MIAProcessCompletionEngineFactory
ProcessMIA
- class populse_mia.user_interface.pipeline_manager.process_mia.MIAProcessCompletionEngine(process, name, fallback_engine)[source]¶
Bases:
ProcessCompletionEngine
A specialized completion engine for all processes within the Populse_mia context.
This engine handles both PopulseMIA processes and NipypeProcess instances with special consideration for their unique requirements:
PopulseMIA processes use their list_outputs method to generate outputs based on input parameters, primarily using filename patterns rather than attributes.
NipypeProcess instances have their MATLAB/SPM settings configured from the application configuration.
The engine also manages project-specific parameters including “project” and “output_directory” when available in the study configuration.
The completion system is augmented with Mia database integration, where attributes from input parameters (called “tags” in Mia) are added to the completion attributes.
This engine tracks completed processes in the correct order, enabling other operations to be performed in the same sequence later.
- Contains:
- Method:
- _complete_mia_process: Complete parameters for Mia-specific
processes.
- _complete_standard_process: Complete parameters for standard
(non-Mia) processes.
- complete_attributes_with_database: Augments the Capsul
completion system attributes associated with a process.
complete_nipype_common: Set Nipype parameters for SPM.
- complete_parameters: Completes file parameters from
given inputs parameters.
- complete_parameters_mia: Completion for
ProcessMIA
instances.
- complete_parameters_mia: Completion for
- get_attribute_values: Get attribute values from the fallback
engine.
- get_path_completion_engine: Get the path completion engine from
the fallback engine.
get_project: Get the project associated with the process
path_attributes: Get path attributes from the fallback engine.
- remove_switch_observe: Reimplemented since it is expects
in switches completion engine.
- __init__(process, name, fallback_engine)[source]¶
Initialize the Mia process completion engine.
- Parameters:
process – The process instance to be completed.
(str) (name) – The name of the process.
fallback_engine – The fallback engine to use when MIA-specific completion is not applicable.
- complete_attributes_with_database(process_inputs=None)[source]¶
Augment the completion attributes with values from the Mia database.
Queries the database for attributes associated with input parameters and adds them to the completion attributes if matches are found.
- Parameters:
(dict) (process_inputs) – Parameters to be set on the process.
- Returns:
The augmented attributes collection.
- static complete_nipype_common(process, output_dir=True)[source]¶
Configure Nipype/SPM parameters for a process.
Sets MATLAB/SPM paths, commands, and project-specific parameters based on the configuration.
- Parameters:
process – The process to configure.
(bool) (output_dir) – If False, the output_directory attribute value is not initialised.
- complete_parameters(process_inputs=None, complete_iterations=True)[source]¶
Complete process parameters based on input values.
This method handles both standard Capsul processes and Mia-specific processes, applying the appropriate completion strategy for each.
- Parameters:
(dict) (process_inputs) – Parameters to be set on the process. May include regular parameters and completion attributes (under ‘capsul_attributes’ key).
(bool) (complete_iterations) – If False, iteration nodes in pipelines will not complete their parameters. This prevents modification of the input pipeline and avoids redundant iterations completion that will be done again during workflow building.
- complete_parameters_mia(process_inputs=None, iteration=False, verbose=False)[source]¶
Complete parameters for ProcessMIA instances.
Uses the ProcessMIA.list_outputs method to generate output parameters based on input values and sets the inheritance_dict for data indexation.
- Parameters:
(dict) (process_inputs) – Parameters to set on the process.
(bool) (verbose) – Whether this completion is for an iteration node.
(bool) – If true, makes the method verbose
- get_attribute_values()[source]¶
Get attribute values from the fallback engine.
- Returns:
The attribute values collection.
- get_path_completion_engine()[source]¶
Get the path completion engine from the fallback engine.
- Returns:
The path completion engine.
- static get_project(process)[source]¶
Get the project associated with a process.
- Parameters:
process – The process to get the project for.
- Returns:
The associated project or None if not found.
- class populse_mia.user_interface.pipeline_manager.process_mia.MIAProcessCompletionEngineFactory[source]¶
Bases:
ProcessCompletionEngineFactory
Specialization of the ProcessCompletionEngineFactory for the Populse Mia context.
This factory is identified by
factory_id = "mia_completion"
and is activated in aStudyConfig
instance by setting the following 2 parameters:- study_config.attributes_schema_paths += [
‘populse_mia.user_interface.pipeline_manager.process_mia’
] study_config.process_completion = ‘mia_completion’
Once activated, the completion system is applied to all processes, distinguishing between MIA and Nipype processes. For standard processes, additional database operations are performed before invoking the underlying completion system (such as FOM or others).
- Contains:
- Method:
get_completion_engine: get a ProcessCompletionEngine instance for a given process/node
- factory_id = 'mia_completion'¶
- get_completion_engine(process, name=None)[source]¶
Retrieves a ProcessCompletionEngine instance for the given process or node.
- Parameters:
Node) (process (Process or) – The process or node for which to get the completion engine.
optional) (name (str,) – An optional name for the completion engine.
- Return (ProcessCompletionEngine):
A completion engine instance associated with the process.
- class populse_mia.user_interface.pipeline_manager.process_mia.ProcessMIA(*args, **kwargs)[source]¶
Bases:
Process
Extends the Capsul Process class to customize execution for Mia bricks.
This class provides specialized methods for Mia bricks, including process initialization, output handling, and trait management.
Note
Type ‘ProcessMIA.help()’ for a full description of this process parameters.
Type ‘<ProcessMIA>.get_input_spec()’ for a full description of this process input trait types.
Type ‘<ProcessMIA>.get_output_spec()’ for a full description of this process output trait types.
- __init__(*args, **kwargs)[source]¶
Initializes the process instance with default attributes.
- Parameters:
(tuple) (args) – Positional arguments passed to the parent class.
(dict) (kwargs) – Keyword arguments passed to the parent class
- ignore = {}¶
- ignore_node = False¶
- init_process(int_name)[source]¶
Instantiate the process attribute given a process identifier.
- Parameters:
(str) (int_name) – A process identifier used to fetch the process instance.
- key = {}¶
- load_nii(file_path, scaled=True, matlab_like=False)[source]¶
Load a NIfTI image and return its header and data, optionally adjusting for MATLAB conventions.
MATLAB and Python (in particular NumPy) treat the order of dimensions and the origin of the coordinate system differently. MATLAB uses main column order (also known as Fortran order). NumPy (and Python in general) uses the order of the main rows (C order). For a 3D array data(x, y, z) in MATLAB, the equivalent in NumPy is data[y, x, z]. MATLAB and NumPy also handle the origin of the coordinate system differently: MATLAB’s coordinate system starts with the origin in the lower left-hand corner (as in traditional matrix mathematics). NumPy’s coordinate system starts with the origin in the top left-hand corner. When taking matlab_like=True as argument, the numpy matrix is rearranged to follow MATLAB conventions. Using scaled=False generates a raw unscaled data matrix (as in MATLAB with header = loadnifti(fnii) and header.reco.data).
- Parameters:
(str) (file_path) – The path to a NIfTI file.
(bool) (matlab_like) – If True the data is scaled.
(bool) – If True the data is rearranged to match the order of the dimensions and the origin of the coordinate system in Matlab.
- relax_nipype_exists_constraints()[source]¶
Relax the ‘exists’ constraint of the process.inputs traits.
- tags_inheritance(in_file, out_file, node_name=None, own_tags=None, tags2del=None)[source]¶
Inherit and manage data tags from input file(s) to an output file.
This method handles the inheritance of metadata tags from one or more input files to an output file. It also allows adding new tags, modifying existing ones, or deleting unwanted tags in the process.
Notes: This method performs inheritance in two ways: 1. Immediate inheritance during process execution 2. Deferred inheritance by storing inheritance information for later
use during workflow generation (addresses issue #290, #310)
In ambiguous cases (multiple input files), the method will either: - Use previously stored inheritance rules - Prompt the user for a decision if no rule exists - Auto-resolve if all inputs have identical tag values
- Parameters:
dict) (own_tags (list of) –
Source of tag inheritance. Either: - A string representing a single input
file path (unambiguous case)
A dictionary mapping plug names to corresponding input file paths (ambiguous case)
(str) (node_name) – Path of the output file that will inherit the tags.
(str) – Name of the processing node in the workflow.
dict) –
Tags to be added or modified. Each dictionary must contain: - “name”: Tag identifier - “field_type”: Data type of the tag - “description”: Human-readable
description
- ”visibility”: Boolean or visibility
level
”origin”: Source of the tag
- ”unit”: Unit of measurement
(if applicable)
”default_value”: Default value
”value”: Current value to set
str) (tags2del (list of) – Tags to be deleted from the output file.
populse_mia.user_interface.pipeline_manager.type_editors module¶
Define the Mia logger.
The soma control classes are overloaded for the needs of Mia.
- Contains:
- Class:
PopulseFileControlWidget
PopulseDirectoryControlWidget
PopulseOffscreenListFileControlWidget
PopulseUndefinedControlWidget
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseDirectoryControlWidget[source]¶
Bases:
DirectoryControlWidget
Widget for selecting a directory.
- Contains:
- Method:
create_widget: Creates the directory selection widget.
filter_clicked: Displays a filtering widget.
- update_plug_value_from_filter: Updates the plug value based on
the filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates and returns a directory selection widget.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_name) – The name of the control.
(Any) (trait) – The initial value of the control.
(Any) – The trait associated with the control.
(Optional[Any]) (label_class) – The label class (optional).
(Optional[dict]) (user_data) – User data associated with the widget.
- Return (QWidget):
The directory selection widget.
- static filter_clicked(widget, node_name, plug_name)[source]¶
Displays a filter widget for selecting a directory.
- Parameters:
(QWidget) (widget) – The calling widget.
(str) (plug_name) – The name of the node.
(str) – The name of the associated plug.
- static update_plug_value_from_filter(widget, plug_name, filter_res_list)[source]¶
Updates the plug value based on the filter result.
If multiple elements are returned, the first one is selected. If the selected element is not a directory, its parent directory is used.
- Parameters:
(QWidget) (widget) – The widget being updated.
(str) (plug_name) – The name of the associated plug.
(list[str]) (filter_res_list) – The list of filtered files.
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseFileControlWidget[source]¶
Bases:
FileControlWidget
Widget control for selecting a file.
Provides methods to create a file selection widget, display a filter dialog, and update plug values based on filter results.
- Contains:
- Method:
create_widget: Method to create the file widget.
filter_clicked: Display a filter widget.
- update_plug_value_from_filter: Update the plug value from
a filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates a file selection widget.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_value) – The name of the control to create.
(str) – The default control value.
(Trait) (trait) – The trait associated with the control.
(Optional[Type[QWidget]]) (label_class) – Custom label widget class.
(Optional[dict]) (user_data) – Additional user data.
- Return (Tuple[QWidget, QLabel]):
A tuple containing the created widget and its associated label. The widget includes a QLineEdit (‘path’) and a browse button (‘browse’).
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseOffscreenListFileControlWidget[source]¶
Bases:
OffscreenListFileControlWidget
A control widget for entering a list of files.
- Contains:
- Method:
create_widget: Creates the list of files widget.
filter_clicked: Displays a filter widget.
- update_plug_value_from_filter: Updates the plug value based on
the filter result.
- static create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None)[source]¶
Creates and returns a file list control widget with an optional filter button.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_name) – The name of the control.
(list) (control_value) – The default control value.
(Trait) (trait) – The trait associated with the control.
(type) (label_class) – A Qt widget class for the label.
(dict) (user_data) – Additional data, including project, scan list, and connected inputs.
- Return (tuple):
A tuple (control widget, (QLabel, QWidget)).
- class populse_mia.user_interface.pipeline_manager.type_editors.PopulseUndefinedControlWidget[source]¶
Bases:
object
Widget control for handling Undefined trait values in a Qt interface.
This class provides methods to create, validate, and update Qt widgets that represent undefined values in a controller-based UI framework.
- Contains:
- Method:
check: Check if a controller widget control is filled correctly.
- connect: Connect a ‘Str’ or ‘String’ controller trait and a
‘StrControlWidget’ controller widget control.
create_widget: Method to create the Undefined widget.
- disconnect: Disconnect a ‘Str’ or ‘String’ controller trait and
a ‘StrControlWidget’ controller widget control.
is_valid: Method to check if the new control value is correct.
update_controller: Update one element of the controller.
- update_controller_widget: Update one element of the controller
widget.
- STYLED_UNDEFINED_TEXT = '<style>background-color: gray; text-color: red;</style><undefined>'¶
- UNDEFINED_TEXT = '<undefined>'¶
- VALID_REPRESENTATIONS = ['<undefined>', '<style>background-color: gray; text-color: red;</style><undefined>']¶
- classmethod check(control_instance)[source]¶
Check if a controller widget control is filled correctly.
This method is a placeholder in this implementation.
- Parameters:
(StrControlWidget) (cls) – A StrControlWidget control.
(QLineEdit) (control_instance) – The control widget to check.
- classmethod connect(controller_widget, control_name, control_instance)[source]¶
Connect a ‘Str’ or ‘String’ controller trait and a ‘StrControlWidget’ controller widget control.
This method is a placeholder in this implementation.
- Parameters:
(StrControlWidget) (cls) – A StrControlWidget control.
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to connect.
(QWidget) (control_instance) – The widget instance to connect
- static create_widget(parent, control_name, label_class=None)[source]¶
Create a widget for displaying Undefined values.
- Parameters:
(QWidget) (parent) – The parent widget.
(str) (control_name) – The name of the control to create.
label_class – The class to use for the label widget. Default is QLabel if None.
- Return (tuple):
(control_widget, label_widget) where control_widget is a QLabel displaying the Undefined value and label_widget is the associated label.
- static disconnect(controller_widget, control_name, control_instance)[source]¶
Disconnect a ‘Str’ or ‘String’ controller trait and a ‘StrControlWidget’ controller widget control.
This method is a placeholder in this implementation.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to disconnect
(QWidget) (control_instance) – The widget instance to disconnect
- static is_valid(control_instance, *args, **kwargs)[source]¶
Validate if the control contains an Undefined value representation.
- Parameters:
(QWidget) (control_instance) – The control widget to validate.
- Return (bool):
True if the control value is Undefined, False otherwise
- static update_controller(controller_widget, control_name, control_instance, reset_invalid_value, *args, **kwargs)[source]¶
Update the controller with the widget’s value if valid.
At the end the controller trait value with the name ‘control_name’ will match the controller widget user parameters defined in ‘control_instance’.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller to update
(str) (control_name) – The name of the control to synchronize with the controller
(QWidget) (control_instance) – The widget instance to synchronize with the controller
(bool) (reset_invalid_value) – If True and the value is invalid, reset the widget to the controller’s value
- static update_controller_widget(controller_widget, control_name, control_instance)[source]¶
Update the widget to reflect the controller’s value.
At the end the controller widget user editable parameter with the name ‘control_name’ will match the controller trait value with the same name.
- Parameters:
(ControllerWidget) (controller_widget) – The controller widget containing the controller.
(str) (control_name) – The name of the control to synchronize.
(QWidget) (control_instance) – The widget instance to update.