sqlite_reader.py

Definition of the SqliteCaseReader.

class openmdao.recorders.sqlite_reader.CaseTable(fname, ver, table, index, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Bases: object

Base class for wrapping case tables in a recording database.

__init__(fname, ver, table, index, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Initialize.

Parameters:
fname : str

The name of the recording file from which to instantiate the case reader.

ver : int

The version of the format assumed when loading the file.

table : str

The name of the table in the database.

index : str

The name of the case index column in the table.

giter : list of tuple

The global iterations table.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

abs2meta : dict

Dictionary mapping absolute variable names to variable metadata.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

voi_meta : dict

Dictionary mapping absolute variable names to variable settings.

cases(cache=False)[source]

Iterate over all cases, optionally caching them into memory.

Parameters:
cache : bool

If True, cases will be cached for faster access by key.

count()[source]

Get the number of cases recorded in the table.

Returns:
int

The number of cases recorded in the table.

get_case(case_id, cache=False)[source]

Get a case from the database.

Parameters:
case_id : str or int

The string-identifier of the case to be retrieved or the index of the case.

cache : bool

If True, case will be cached for faster access by key.

Returns:
Case

The specified case from the table.

get_cases(source=None, recurse=False, flat=False)[source]

Get list of case names for cases in the table.

Parameters:
source : str, optional

If not None, only cases that have the specified source will be returned

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases from the table that have the specified source.

list_cases(source=None)[source]

Get list of case IDs for cases in the table.

Parameters:
source : str, optional

A source of cases or the iteration coordinate of a case. If not None, only cases originating from the specified source or case are returned.

Returns:
list

The cases from the table from the specified source or parent case.

list_sources()[source]

Get the list of sources that recorded data in this table.

Returns:
list

List of sources.

class openmdao.recorders.sqlite_reader.DriverCases(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

Cases specific to the entries that might be recorded in a Driver iteration.

__init__(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Initialize.

Parameters:
filename : str

The name of the recording file from which to instantiate the case reader.

format_version : int

The version of the format assumed when loading the file.

giter : list of tuple

The global iterations table.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

abs2meta : dict

Dictionary mapping absolute variable names to variable metadata.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

voi_meta : dict

Dictionary mapping absolute variable names to variable settings.

cases(cache=False)[source]

Iterate over all cases, optionally caching them into memory.

Override base class to add derivatives from the derivatives table.

Parameters:
cache : bool

If True, cases will be cached for faster access by key.

count()

Get the number of cases recorded in the table.

Returns:
int

The number of cases recorded in the table.

get_case(case_id, cache=False)[source]

Get a case from the database.

Parameters:
case_id : int or str

The integer index or string-identifier of the case to be retrieved.

cache : bool

If True, cache the case so it does not have to be fetched on next access.

Returns:
Case

The specified case from the driver_iterations and driver_derivatives tables.

get_cases(source=None, recurse=False, flat=False)

Get list of case names for cases in the table.

Parameters:
source : str, optional

If not None, only cases that have the specified source will be returned

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases from the table that have the specified source.

list_cases(source=None)

Get list of case IDs for cases in the table.

Parameters:
source : str, optional

A source of cases or the iteration coordinate of a case. If not None, only cases originating from the specified source or case are returned.

Returns:
list

The cases from the table from the specified source or parent case.

list_sources()[source]

Get the list of sources that recorded data in this table (just the driver).

Returns:
list

List of sources.

class openmdao.recorders.sqlite_reader.ProblemCases(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

Cases specific to the entries that might be recorded in a Driver iteration.

__init__(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Initialize.

Parameters:
filename : str

The name of the recording file from which to instantiate the case reader.

format_version : int

The version of the format assumed when loading the file.

giter : list of tuple

The global iterations table.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

abs2meta : dict

Dictionary mapping absolute variable names to variable metadata.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

voi_meta : dict

Dictionary mapping absolute variable names to variable settings.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cache : bool

If True, cases will be cached for faster access by key.

count()

Get the number of cases recorded in the table.

Returns:
int

The number of cases recorded in the table.

get_case(case_id, cache=False)

Get a case from the database.

Parameters:
case_id : str or int

The string-identifier of the case to be retrieved or the index of the case.

cache : bool

If True, case will be cached for faster access by key.

Returns:
Case

The specified case from the table.

get_cases(source=None, recurse=False, flat=False)

Get list of case names for cases in the table.

Parameters:
source : str, optional

If not None, only cases that have the specified source will be returned

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases from the table that have the specified source.

list_cases(source=None)

Get list of case IDs for cases in the table.

Parameters:
source : str, optional

A source of cases or the iteration coordinate of a case. If not None, only cases originating from the specified source or case are returned.

Returns:
list

The cases from the table from the specified source or parent case.

list_sources()[source]

Get the list of sources that recorded data in this table (just the problem).

Returns:
list

List of sources.

class openmdao.recorders.sqlite_reader.SolverCases(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

Cases specific to the entries that might be recorded in a Solver iteration.

__init__(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Initialize.

Parameters:
filename : str

The name of the recording file from which to instantiate the case reader.

format_version : int

The version of the format assumed when loading the file.

giter : list of tuple

The global iterations table.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

abs2meta : dict

Dictionary mapping absolute variable names to variable metadata.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

voi_meta : dict

Dictionary mapping absolute variable names to variable settings.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cache : bool

If True, cases will be cached for faster access by key.

count()

Get the number of cases recorded in the table.

Returns:
int

The number of cases recorded in the table.

get_case(case_id, cache=False)

Get a case from the database.

Parameters:
case_id : str or int

The string-identifier of the case to be retrieved or the index of the case.

cache : bool

If True, case will be cached for faster access by key.

Returns:
Case

The specified case from the table.

get_cases(source=None, recurse=False, flat=False)

Get list of case names for cases in the table.

Parameters:
source : str, optional

If not None, only cases that have the specified source will be returned

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases from the table that have the specified source.

list_cases(source=None)

Get list of case IDs for cases in the table.

Parameters:
source : str, optional

A source of cases or the iteration coordinate of a case. If not None, only cases originating from the specified source or case are returned.

Returns:
list

The cases from the table from the specified source or parent case.

list_sources()

Get the list of sources that recorded data in this table.

Returns:
list

List of sources.

class openmdao.recorders.sqlite_reader.SqliteCaseReader(filename, pre_load=False)[source]

Bases: openmdao.recorders.base_case_reader.BaseCaseReader

A CaseReader specific to files created with SqliteRecorder.

Attributes

problem_metadata (dict) Metadata about the problem, including the system hierachy and connections.
solver_metadata (dict) The solver options for each solver in the recorded model.
system_metadata (dict) Metadata about each system in the recorded model, including options and scaling factors.
__init__(filename, pre_load=False)[source]

Initialize.

Parameters:
filename : str

The path to the filename containing the recorded data.

pre_load : bool

If True, load all the data into memory during initialization.

get_case(case_id, recurse=False)[source]

Get case identified by case_id.

Parameters:
case_id : str or int

The unique identifier of the case to return or an index into all cases.

recurse : bool, optional

If True, will return all successors to the case as well.

Returns:
dict

The case identified by case_id

get_cases(source=None, recurse=True, flat=False)[source]

Iterate over the cases.

Parameters:
source : {‘problem’, ‘driver’, component pathname, solver pathname, iteration_coordinate}

Identifies which cases to return.

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases identified by source

list_cases(source=None, recurse=True, flat=True)[source]

Iterate over Driver, Solver and System cases in order.

Parameters:
source : {‘problem’, ‘driver’, component pathname, solver pathname, iteration_coordinate}

If not None, only cases originating from the specified source or case are returned.

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy.

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
iterator or dict

An iterator or a nested dictionary of identified cases.

list_source_vars(source)[source]

List of all inputs and outputs recorded by the specified source.

Parameters:
source : {‘problem’, ‘driver’, component pathname, solver pathname}

Identifies the source for which to return information.

Returns:
dict

{‘inputs’:[list of keys], ‘outputs’:[list of keys]}. Does not recurse.

list_sources()[source]

List of all the different recording sources for which there is recorded data.

Returns:
list

One or more of: problem, driver, <component hierarchy location>, <solver hierarchy location>

class openmdao.recorders.sqlite_reader.SystemCases(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

Cases specific to the entries that might be recorded in a System iteration.

__init__(filename, format_version, giter, prom2abs, abs2prom, abs2meta, voi_meta)[source]

Initialize.

Parameters:
filename : str

The name of the recording file from which to instantiate the case reader.

format_version : int

The version of the format assumed when loading the file.

giter : list of tuple

The global iterations table.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

abs2meta : dict

Dictionary mapping absolute variable names to variable metadata.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

voi_meta : dict

Dictionary mapping absolute variable names to variable settings.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cache : bool

If True, cases will be cached for faster access by key.

count()

Get the number of cases recorded in the table.

Returns:
int

The number of cases recorded in the table.

get_case(case_id, cache=False)

Get a case from the database.

Parameters:
case_id : str or int

The string-identifier of the case to be retrieved or the index of the case.

cache : bool

If True, case will be cached for faster access by key.

Returns:
Case

The specified case from the table.

get_cases(source=None, recurse=False, flat=False)

Get list of case names for cases in the table.

Parameters:
source : str, optional

If not None, only cases that have the specified source will be returned

recurse : bool, optional

If True, will enable iterating over all successors in case hierarchy

flat : bool, optional

If False and there are child cases, then a nested ordered dictionary is returned rather than an iterator.

Returns:
list or dict

The cases from the table that have the specified source.

list_cases(source=None)

Get list of case IDs for cases in the table.

Parameters:
source : str, optional

A source of cases or the iteration coordinate of a case. If not None, only cases originating from the specified source or case are returned.

Returns:
list

The cases from the table from the specified source or parent case.

list_sources()

Get the list of sources that recorded data in this table.

Returns:
list

List of sources.