bout_runners.metadata.metadata_recorder

Module containing the MetadataRecorder class.

Classes

MetadataRecorder(db_connector, bout_paths, …)

Class for recording the metadata of the runs.

class bout_runners.metadata.metadata_recorder.MetadataRecorder(db_connector: bout_runners.database.database_connector.DatabaseConnector, bout_paths: bout_runners.parameters.bout_paths.BoutPaths, final_parameters: bout_runners.parameters.final_parameters.FinalParameters)[source]

Class for recording the metadata of the runs.

Examples

Import dependencies

>>> from pathlib import Path
>>> from bout_runners.executor.bout_paths import BoutPaths
>>> from bout_runners.parameters.default_parameters import DefaultParameters
>>> from bout_runners.parameters.final_parameters import FinalParameters
>>> from bout_runners.database.database_connector import DatabaseConnector
>>> from bout_runners.submitter.processor_split import ProcessorSplit

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)

Obtain the parameters

>>> default_parameters = DefaultParameters(bout_paths)
>>> final_parameters = FinalParameters(default_parameters)
>>> final_parameters_dict = final_parameters.get_final_parameters()
>>> final_parameters_as_sql_types = \
...     final_parameters.cast_to_sql_type(
...     final_parameters_dict)

Create the metadata recorder object

>>> db_connector = DatabaseConnector('name', project_path)
>>> metadata_recorder = MetadataRecorder(db_connector,
...                                      bout_paths,
...                                      final_parameters)

Capture the data to the database

>>> metadata_recorder.capture_new_data_from_run(ProcessorSplit())
None
Attributes
__db_writerDatabaseWriter

Getter variable for db_writer

__db_readerDatabaseReader

Getter variable for db_reader

db_writerDatabaseWriter

Set the properties of self.db_writer.

db_readerDatabaseReader

Set the properties of self.db_reader.

Methods

capture_new_data_from_run(runner, processor_split)

Capture new data from a run

_create_parameter_tables_entry(parameters_dict)

Insert the parameters into a the parameter tables

Set the database to use.

Parameters
db_connectorDatabaseConnector

The database connector

bout_pathsBoutPaths

Object containing the paths

final_parametersFinalParameters

Object containing the final parameters

Attributes
db_reader

Set the properties of self.db_reader.

db_writer

Set the properties of self.db_writer.

Methods

capture_new_data_from_run(processor_split[, …])

Capture new data from a run.

create_entry(table_name, entries_dict)

Create a database entry and return the entry id.

capture_new_data_from_run(processor_split: bout_runners.submitter.processor_split.ProcessorSplit, restart: bool = False, force: bool = False) → Optional[int][source]

Capture new data from a run.

This function will capture all uncaptured data from a run. If all data has been captured previously, it means that the run has already been executed, and new_entry = False will be returned.

Parameters
processor_splitProcessorSplit

The processor split object

restartbool

If True, the data will be captured (even if it has been executed before)

forcebool

Store entry to the run table even if a entry with the same parameter exists This will typically be used if the bout_runners is forcefully executing a run

Returns
run_idNone or int

If no previous run with the same configuration has been executed, this will return None, else the run_id is returned

create_entry(table_name: str, entries_dict: Mapping[str, Optional[Union[int, str, float]]]) → int[source]

Create a database entry and return the entry id.

Parameters
table_namestr

Name of the table

entries_dictdict

Dictionary containing the entries as key value pairs

Returns
entry_idint

The id of the newly created entry

Raises
RuntimeError

If the newly created id could not be fetched

property db_reader

Set the properties of self.db_reader.

Returns
self.__db_readerDatabaseReader

The database reader object

Notes

The db_reader is read only

property db_writer

Set the properties of self.db_writer.

Returns
self.__db_writerDatabaseWriter

The database writer object

Notes

The db_writer is read only