bout_runners.runner.run_group¶
Contains the RunGroup class.
Classes
|
Class for building a run group. |
-
class
bout_runners.runner.run_group.
RunGroup
(run_graph: bout_runners.runner.run_graph.RunGraph, bout_run_setup: bout_runners.parameters.bout_run_setup.BoutRunSetup, name: Optional[str] = None, waiting_for: Optional[Union[str, Iterable[str]]] = None)[source]¶ Class for building a run group.
A run group contains one recipe for executing the project (called bout_run_setup). The run group may consist of pre-processors (functions that will run prior to the bout_run_setup execution), and it may consist of post-processors (functions that will run after the bout_run_setup execution).
See also
RunGraph
Class to create a run graph
Examples
The RunGroup contains the a bout run and it’s pre- and post-processors
>>> bout_run_setup = BoutRunSetup(executor, db_connector, final_parameters) >>> run_graph = RunGraph() >>> # Attach a RunGroups to the run_graph >>> run_group_1 = RunGroup(run_graph, bout_run_setup_1) >>> run_group_2 = RunGroup(run_graph, bout_run_setup_2) >>> # Add the function `foo` as a post-processor to run_group_1 >>> post_processor_node_name = run_group_1.add_post_processor( ... {'function': foo, 'args': (foo_1,), 'kwargs':None}) >>> # Add the function `bar` as a pre-processor to run_group_2, ... # which waits for the post-processor of run_group_1 >>> run_group_2.add_pre_processor( ... {'function': bar, 'args': None, 'kwargs':None}), ... waiting_for=post_processor_node_name) >>> runner = BoutRunner(run_graph) >>> runner.run()
- Attributes
- __counterint
Counter used if no name is given in the constructor
- __nameslist of str
List of the run group names, makes sure there will be no name collision
- __dst_dirPath
The path to the dump directory
- __namestr
Name of the RunGroup
- __run_graphRunGraph
The getter variable of run_graph
- __bout_run_setupBoutRunSetup
The setup of the BOUT++ run
- __bout_run_node_namestr
Getter variable for bout_run_node_name
- __pre_processorslist of str
Getter variable for pre_processors
- __post_processorslist of str
Getter variable for post_processors
bout_run_node_name
strReturn the name of the BOUT++ run node.
bout_paths
BoutPathsReturn the BoutPaths.
db_connector
DatabaseConnectorReturn the DatabaseConnector.
run_graph
RunGraphReturn the run graph.
pre_processors
list of strReturn the pre_processors.
post_processors
list of strReturn the post_processors.
Methods
__increment_name()
Increment the name with a number to avoid name collision
add_pre_processor(function_dict, directory, submitter, waiting_for)
Add a function which will run prior to the BOUT++ run
add_post_processor(function_dict, directory, submitter, waiting_for)
Add a function which will run after the BOUT++ run
Set the member data.
If you want to connect nodes to this RunGroup after creation, you can use RunGraph.add_function_node
- Parameters
- run_graphRunGraph
The RunGraph which the RunGroup will be attached to
- bout_run_setupBoutRunSetup
The setup of the BOUT++ run
- nameNone or str
Name of the RunGroup If None, the class counter will be used
- waiting_forNone or str or iterable
Name of nodes the name_of_waiting_node will wait for
- Attributes
bout_paths
Return the BoutPaths.
bout_run_node_name
Return the name of the BOUT++ run node.
db_connector
Return the DatabaseConnector.
post_processors
Return the post_processors.
pre_processors
Return the pre_processors.
run_graph
Return the run graph.
Methods
add_post_processor
(function_dict[, …])Add a post-processor to the BOUT++ run.
add_pre_processor
(function_dict[, …])Add a pre-processor to the BOUT++ run.
-
add_post_processor
(function_dict: Dict[str, Optional[Union[Callable, Tuple[Any, …], Dict[str, Any]]]], directory: Optional[pathlib.Path] = None, submitter: Optional[bout_runners.submitter.abstract_submitter.AbstractSubmitter] = None, waiting_for: Optional[Union[str, Iterable[str]]] = None) → str[source]¶ Add a post-processor to the BOUT++ run.
The function and the parameters will be saved to a python script which will be submitted
- Parameters
- function_dictdict
Dict with the function to call On the form >>> {‘function’: callable, … ‘args’: None or tuple, … ‘kwargs’: None or dict}
- directoryNone or Path
Absolute path to directory to store the python script If None, the destination directory of BoutRun will be used
- waiting_forNone or str or iterable
Name of nodes this node will wait for to finish before executing
- submitterNone or AbstractSubmitter
Submitter to submit the function with If None, the default LocalSubmitter will be used
- Returns
- post_processor_node_namestr
The node name of the pre-processor
- Raises
- ValueError
If the function in the function_dict is not callable
-
add_pre_processor
(function_dict: Dict[str, Optional[Union[Callable, Tuple[Any, …], Dict[str, Any]]]], directory: Optional[pathlib.Path] = None, submitter: Optional[bout_runners.submitter.abstract_submitter.AbstractSubmitter] = None, waiting_for: Optional[Union[str, Iterable[str]]] = None) → str[source]¶ Add a pre-processor to the BOUT++ run.
The function and the parameters will be saved to a python script which will be submitted
- Parameters
- function_dictdict
Dict with the function to call On the form >>> {‘function’: callable, … ‘args’: None or tuple, … ‘kwargs’: None or dict}
- directoryNone or Path
Absolute path to directory to store the python script If None, the destination directory of BoutRun will be used
- submitterAbstractSubmitter
Submitter to submit the function with If None, the default LocalSubmitter will be used
- waiting_forNone or str or iterable
Name of nodes this node will wait for to finish before executing
- Returns
- pre_processor_node_namestr
The node name of the pre-processor
- Raises
- ValueError
If the function in the function_dict is not callable
-
property
bout_paths
¶ Return the BoutPaths.
- Returns
- BoutPaths
The BoutPaths
-
property
bout_run_node_name
¶ Return the name of the BOUT++ run node.
- Returns
- str
The name of the BOUT++ run node
-
property
db_connector
¶ Return the DatabaseConnector.
- Returns
- BoutPaths
The DatabaseConnector
-
property
post_processors
¶ Return the post_processors.
- Returns
- tuple
The tuple of post_processors
-
property
pre_processors
¶ Return the pre_processors.
- Returns
- tuple
The tuple of pre_processors
-
property
run_graph
¶ Return the run graph.
- Returns
- RunGraph
The run graph