bout_runners.runner.bout_run_executor

Contains the executor class.

Classes

BoutRunExecutor(bout_paths, submitter, …)

Executes the command for submitting a bout run.

class bout_runners.runner.bout_run_executor.BoutRunExecutor(bout_paths: Optional[bout_runners.parameters.bout_paths.BoutPaths] = None, submitter: Optional[bout_runners.submitter.abstract_submitter.AbstractSubmitter] = None, run_parameters: Optional[bout_runners.parameters.run_parameters.RunParameters] = None, restart_from: Optional[pathlib.Path] = None)[source]

Executes the command for submitting a bout run.

Examples

The easiest way to use the Executor is to run a script from the root directory of the project (i.e. where the Makefile and data directory are normally situated. The script can simply call

>>> BoutRunExecutor().execute()

and Executor takes care of the rest.

A more elaborate example where all the dependency objects are built manually:

Import the dependencies

>>> from pathlib import Path
>>> from bout_runners.executor.bout_paths import BoutPaths
>>> from bout_runners.submitter.local_submitter import LocalSubmitter

Create the bout_paths object

>>> project_path = Path().joinpath('path', 'to', 'project')
>>> bout_inp_src_dir = Path().joinpath('path', 'to', 'source', 'BOUT.inp')
>>> bout_inp_dst_dir = Path().joinpath('path', 'to', 'destination', 'BOUT.inp')
>>> bout_paths = BoutPaths(project_path=project_path,
...                        bout_inp_src_dir=bout_inp_src_dir,
...                        bout_inp_dst_dir=bout_inp_dst_dir)

Create the executor object

>>> run_parameters = RunParameters({'global': {'nout': 0}})
>>> executor = BoutRunExecutor(
...     bout_paths=bout_paths,
...     submitter=LocalSubmitter(bout_paths.project_path),
...     run_parameters=run_parameters)

Execute the run

>>> executor.execute()
Attributes
__bout_pathsBoutPaths

Getter variable for project_path

__makeMake

Object for making the project

__run_parametersRunParameters

Object containing the run parameters

bout_pathsBoutPaths

Get the properties of self.bout_paths.

exec_namestr

Set the properties of self.bout_paths.

restart_fromNone or Path

Set the properties of self.restart from and update bout_inp_dst_dir.

run_parametersRunParameters

Get the properties of self.run_parameters.

submitterAbstractSubmitter

Object containing the submitter

Methods

get_execute_command()

Return the execute command string

execute()

Execute a BOUT++ run

Set the input parameters.

Parameters
bout_pathsBoutPaths or None

Object containing the paths If None, default BoutPaths values will be used

submitterAbstractSubmitter

Object containing the submitter

run_parametersRunParameters or None

Object containing the run parameters If None, default parameters will be used

restart_fromPath or None

The path to copy the restart files from

Attributes
bout_paths

Get the properties of self.bout_paths.

exec_name

Set the properties of self.bout_paths.

restart_from

Set the properties of self.restart from and update bout_inp_dst_dir.

run_parameters

Get the properties of self.run_parameters.

Methods

execute([restart])

Execute a BOUT++ run.

get_execute_command()

Return the execute command string.

property bout_paths

Get the properties of self.bout_paths.

Returns
self.__bout_pathsBoutPaths

Object containing the paths

Notes

The bout_paths is read only

property exec_name

Set the properties of self.bout_paths.

Returns
self.__bout_pathsBoutPaths

Object containing the paths

Notes

The exec_name is read only

execute(restart: bool = False) → None[source]

Execute a BOUT++ run.

Parameters
restartbool

If True the ‘restart’ will be appended to the command string

get_execute_command() → str[source]

Return the execute command string.

Returns
commandstr

The terminal command for executing the run

property restart_from

Set the properties of self.restart from and update bout_inp_dst_dir.

The bout_inp_dst_dir is updated to reflect that this is a restart run.

The new bout_inp_dst_dir will be the same as bout_run_setup.executor.restart_from with _restart_/d* appended /d* will be the next digit based on the number of other restart directories

See also

bout_runners.runner.bout_runner.BoutRunner.__inject_copy_restart_files_node

Search for restart files, make a restart node where needed

Notes

This will not copy the restart files as the restart files may not be ready. Copying of files can either be done manually using bout_runner.utils.file_operations.copy_restart_files or automatically by using BoutRunner.__inject_copy_restart_files_node which is called from BoutRunner.__prepare_run

property run_parameters

Get the properties of self.run_parameters.

Returns
self.__run_parametersRunParameters

Object containing the run parameters

Notes

The run_parameters is read only