sqlite_reader.py

Definition of the SqliteCaseReader.

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

Bases: object

Base class for wrapping case tables in a recording database.

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

Initialize.

Parameters
fnamestr

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

verint

The version of the format assumed when loading the file.

tablestr

The name of the table in the database.

indexstr

The name of the case index column in the table.

giterlist of tuple

The global iterations table.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

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

Dictionary mapping promoted names to absolute names.

var_infodict

Dictionary with information about variables (scaling, indices, execution order).

cases(self, cache=False)[source]

Iterate over all cases, optionally caching them into memory.

Parameters
cachebool

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

count(self)[source]

Get the number of cases recorded in the table.

Returns
int

The number of cases recorded in the table.

get_case(self, case_id, cache=False)[source]

Get a case from the database.

Parameters
case_idstr or int

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

cachebool

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

Returns
Case

The specified case from the table.

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

Get list of case names for cases in the table.

Parameters
sourcestr, optional

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

recursebool, optional

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

flatbool, 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(self, source=None)[source]

Get list of case IDs for cases in the table.

Parameters
sourcestr, 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(self)[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, var_info)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

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

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

Initialize.

Parameters
filenamestr

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

format_versionint

The version of the format assumed when loading the file.

giterlist of tuple

The global iterations table.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

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

Dictionary mapping promoted names to absolute names.

var_infodict

Dictionary with information about variables (scaling, indices, execution order).

cases(self, cache=False)[source]

Iterate over all cases, optionally caching them into memory.

Override base class to add derivatives from the derivatives table.

Parameters
cachebool

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

count(self)

Get the number of cases recorded in the table.

Returns
int

The number of cases recorded in the table.

get_case(self, case_id, cache=False)[source]

Get a case from the database.

Parameters
case_idint or str

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

cachebool

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(self, source=None, recurse=False, flat=False)

Get list of case names for cases in the table.

Parameters
sourcestr, optional

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

recursebool, optional

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

flatbool, 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(self, source=None)

Get list of case IDs for cases in the table.

Parameters
sourcestr, 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(self)[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, var_info)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

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

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

Initialize.

Parameters
filenamestr

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

format_versionint

The version of the format assumed when loading the file.

giterlist of tuple

The global iterations table.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

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

Dictionary mapping promoted names to absolute names.

var_infodict

Dictionary with information about variables (scaling, indices, execution order).

cases(self, cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters
cachebool

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

count(self)

Get the number of cases recorded in the table.

Returns
int

The number of cases recorded in the table.

get_case(self, case_id, cache=False)

Get a case from the database.

Parameters
case_idstr or int

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

cachebool

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

Returns
Case

The specified case from the table.

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

Get list of case names for cases in the table.

Parameters
sourcestr, optional

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

recursebool, optional

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

flatbool, 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(self, source=None)

Get list of case IDs for cases in the table.

Parameters
sourcestr, 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(self)[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, var_info)[source]

Bases: openmdao.recorders.sqlite_reader.CaseTable

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

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

Initialize.

Parameters
filenamestr

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

format_versionint

The version of the format assumed when loading the file.

giterlist of tuple

The global iterations table.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

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

Dictionary mapping promoted names to absolute names.

var_infodict

Dictionary with information about variables (scaling, indices, execution order).

cases(self, cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters
cachebool

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

count(self)

Get the number of cases recorded in the table.

Returns
int

The number of cases recorded in the table.

get_case(self, case_id, cache=False)

Get a case from the database.

Parameters
case_idstr or int

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

cachebool

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

Returns
Case

The specified case from the table.

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

Get list of case names for cases in the table.

Parameters
sourcestr, optional

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

recursebool, optional

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

flatbool, 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(self, source=None)

Get list of case IDs for cases in the table.

Parameters
sourcestr, 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(self)

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__(self, filename, pre_load=False)[source]

Initialize.

Parameters
filenamestr

The path to the filename containing the recorded data.

pre_loadbool

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

get_case(self, case_id, recurse=False)[source]

Get case identified by case_id.

Parameters
case_idstr or int

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

recursebool, optional

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

Returns
dict

The case identified by case_id

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

Iterate over the cases.

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

Identifies which cases to return.

recursebool, optional

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

flatbool, 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(self, source=None, recurse=True, flat=True)[source]

Iterate over Driver, Solver and System cases in order.

Parameters
source{‘problem’, ‘driver’, <system hierarchy location>, <solver hierarchy location>,

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

recursebool, optional

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

flatbool, 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(self, source)[source]

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

Parameters
source{‘problem’, ‘driver’, <system hierarchy location>, <solver hierarchy location>}

Identifies the source for which to return information.

Returns
dict

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

list_sources(self)[source]

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

Returns
list
One or more of: problem, driver, <system hierarchy location>,

<solver hierarchy location>

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

Bases: openmdao.recorders.sqlite_reader.CaseTable

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

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

Initialize.

Parameters
filenamestr

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

format_versionint

The version of the format assumed when loading the file.

giterlist of tuple

The global iterations table.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

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

Dictionary mapping promoted names to absolute names.

var_infodict

Dictionary with information about variables (scaling, indices, execution order).

cases(self, cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters
cachebool

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

count(self)

Get the number of cases recorded in the table.

Returns
int

The number of cases recorded in the table.

get_case(self, case_id, cache=False)

Get a case from the database.

Parameters
case_idstr or int

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

cachebool

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

Returns
Case

The specified case from the table.

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

Get list of case names for cases in the table.

Parameters
sourcestr, optional

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

recursebool, optional

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

flatbool, 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(self, source=None)

Get list of case IDs for cases in the table.

Parameters
sourcestr, 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(self)

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

Returns
list

List of sources.