bout_runners.runner.bout_runner

Contains the BOUT runner class.

Classes

BoutRunner(executor, db_connector, …)

Class for executing a run and store its metadata.

class bout_runners.runner.bout_runner.BoutRunner(executor: Optional[bout_runners.executor.executor.Executor] = None, db_connector: Optional[bout_runners.database.database_connector.DatabaseConnector] = None, final_parameters: Optional[bout_runners.parameters.final_parameters.FinalParameters] = None)[source]

Class for executing a run and store its metadata.

Examples

The easiest way to use BoutRunner 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

>>> BoutRunner().run()

and BoutRunner takes care of the rest.

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

Import dependencies

>>> from pathlib import Path
>>> from bout_runners.executor.bout_paths import BoutPaths
>>> from bout_runners.executor.executor import Executor
>>> from bout_runners.database.database_connector import DatabaseConnector
>>> from bout_runners.parameters.default_parameters import DefaultParameters
>>> from bout_runners.parameters.run_parameters import RunParameters
>>> from bout_runners.parameters.final_parameters import FinalParameters
>>> 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 input objects

>>> default_parameters = DefaultParameters(bout_paths)
>>> run_parameters = RunParameters({'global': {'nout': 0}})
>>> final_parameters = FinalParameters(default_parameters,
...                                    run_parameters)
>>> executor = Executor(
...     bout_paths=bout_paths,
...     submitter=LocalSubmitter(bout_paths.project_path),
...     run_parameters=run_parameters)
>>> db_connection = DatabaseConnector('name_of_database', db_root_path=Path())

Run the project

>>> runner = BoutRunner(executor,
...                     db_connection,
...                     final_parameters)
>>> runner.run()
Attributes
self.__executorExecutor

Getter variable for executor

self.__db_connectorDatabaseConnector

Getter variable for db_connector

self.__final_parametersFinalParameters

Getter variable for final_parameters

self.__db_creatorDatabaseCreator

Object used to create the database

self.__metadata_recorderMetadataRecorder

Object used to record the metadata about a run

self.executorExecutor

Object used to execute the run

self.db_creatorDatabaseCreator

Object used to create the database

self.final_parametersFinalParameters

Object containing the parameters to use

Methods

create_schema()

Create the schema

run(force)

Execute the run

Set the member data.

Parameters
executorExecutor or None

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

db_connectorDatabaseConnector or None

The connection to the database If None: Default database connector will be used

final_parametersFinalParameters or None

The object containing the parameters which are going to be used in the run If None, default parameters will be used

Attributes
db_connector

Get the properties of self.db_connector.

executor

Get the properties of self.executor.

final_parameters

Get the properties of self.final_parameters.

Methods

create_schema(self)

Create the schema.

run(self, force)

Perform the run and capture data.

create_schema(self) → None[source]

Create the schema.

property db_connector

Get the properties of self.db_connector.

Returns
self.__db_connectorDatabaseConnector

The object holding the database connection

property executor

Get the properties of self.executor.

Returns
self.__executorExecutor

The executor object

property final_parameters

Get the properties of self.final_parameters.

Returns
self.__final_parametersFinalParameters

The object containing the parameters used in the run

run(self, force: bool = False) → None[source]

Perform the run and capture data.

Parameters
forcebool

Execute the run even if has been performed with the same parameters