sqlite_reader.py#

Definition of the SqliteCaseReader.

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

Bases: object

Base class for wrapping case tables in a recording database.

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.

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

Dictionary mapping promoted names to absolute names.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

connsdict

Dictionary of all model connections.

auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

var_infodict

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

Attributes:
_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.

_table_namestr

The name of the table in the database.

_index_namestr

The name of the case index column in the table.

_global_iterationslist

List of iteration cases and the table and row in which they are found.

_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.

_connsdict

Dictionary of all model connections.

_var_infodict

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

_sourceslist

List of sources of cases in the table.

_keyslist

List of keys of cases in the table.

_casesdict

Dictionary mapping keys to cases that have already been loaded.

_auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

_global_iterationslist

List of iteration cases and the table and row in which they are found.

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

Initialize.

cases(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.

Yields:
case
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_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(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(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()[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, conns, auto_ivc_map, var_info)[source]

Bases: CaseTable

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

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.

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

Dictionary mapping promoted names to absolute names.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

connsdict

Dictionary of all model connections.

auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

var_infodict

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

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

Initialize.

cases(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.

Yields:
case
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_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(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(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()[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, conns, auto_ivc_map, var_info)[source]

Bases: CaseTable

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

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.

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

Dictionary mapping promoted names to absolute names.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

connsdict

Dictionary of all model connections.

auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

var_infodict

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

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

Initialize.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cachebool

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

Yields:
case
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_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(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(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()[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, conns, auto_ivc_map, var_info)[source]

Bases: CaseTable

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

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.

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

Dictionary mapping promoted names to absolute names.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

connsdict

Dictionary of all model connections.

auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

var_infodict

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

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

Initialize.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cachebool

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

Yields:
case
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_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(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(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()

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, metadata_filename=None)[source]

Bases: BaseCaseReader

A CaseReader specific to files created with SqliteRecorder.

Parameters:
filenamestr or pathlib.Path

The path to the filename containing the recorded data.

pre_loadbool

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

metadata_filenamestr

The path to the filename containing the recorded metadata, if separate.

Attributes:
problem_metadatadict

Metadata about the problem, including the system hierachy and connections.

solver_metadatadict

The solver options for each solver in the recorded model.

_system_optionsdict

Metadata about each system in the recorded model, including options and scaling factors.

_format_versionint

The version of the format assumed when loading the file.

_filenamestr

The path to the filename containing the recorded data.

_abs2metadict

Dictionary mapping variables to their metadata

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

Dictionary mapping absolute names to promoted names.

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

Dictionary mapping promoted names to absolute names.

_connsdict

Dictionary of all model connections.

_auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

_driver_casesDriverCases

Helper object for accessing cases from the driver_iterations table.

_system_casesSystemCases

Helper object for accessing cases from the system_iterations table.

_solver_casesSolverCases

Helper object for accessing cases from the solver_iterations table.

_problem_casesProblemCases

Helper object for accessing cases from the problem_cases table.

_global_iterationslist

List of iteration cases and the table and row in which they are found.

__init__(filename, pre_load=False, metadata_filename=None)[source]

Initialize.

get_case(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(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(source=None, recurse=True, flat=True, out_stream=DEFAULT_OUT_STREAM)[source]

Iterate over Driver, Solver and System cases in order.

Parameters:
source‘problem’, ‘driver’, component pathname, solver pathname, 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.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
iterator or dict

An iterator or a nested dictionary of identified cases.

list_model_options(run_number=0, system=None, out_stream=DEFAULT_OUT_STREAM)[source]

List model options for the specified run.

Parameters:
run_numberint

Run_driver or run_model iteration to inspect.

systemstr or None

Pathname of system (None for all systems).

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{system: {key: val}}.

list_solver_options(run_number=0, solver=None, out_stream=DEFAULT_OUT_STREAM)[source]

List solver options for the specified run.

Parameters:
run_numberint

Run_driver or run_model iteration to inspect.

solverstr or None

Pathname of solver (None for all solvers).

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{solver: {key: val}}.

list_source_vars(source, out_stream=DEFAULT_OUT_STREAM)[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.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

{‘inputs’:[key list], ‘outputs’:[key list], ‘residuals’:[key list]}. No recurse.

list_sources(out_stream=DEFAULT_OUT_STREAM)[source]

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

Parameters:
out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

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

<solver hierarchy location>

property openmdao_version

Provide the version of OpenMDAO that was used to record this file.

Returns:
str

version of OpenMDAO that was used to record this file.

systems(tree=None, path=None, paths=[])[source]

List pathnames of systems in the system hierarchy.

Parameters:
treedict

Nested dictionary of system information.

pathstr or None

Pathname of root system (None for the root model).

pathslist

List to which pathnames are appended.

Returns:
list

List of pathnames of systems.

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

Bases: CaseTable

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

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.

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

Dictionary mapping promoted names to absolute names.

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

Dictionary mapping absolute names to promoted names.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

connsdict

Dictionary of all model connections.

auto_ivc_mapdict

Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.

var_infodict

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

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

Initialize.

cases(cache=False)

Iterate over all cases, optionally caching them into memory.

Parameters:
cachebool

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

Yields:
case
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_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(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(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()

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

Returns:
list

List of sources.

class openmdao.recorders.sqlite_reader.UnknownType(**kwargs)[source]

Bases: object

A class used by _RestrictedUnpickler.

Used to indicate the unpickler can’t generate an instance of a class whose class definition is not available

Parameters:
*argslist

Positional args.

**kwargsdict

Keyword args.

__init__(**kwargs)[source]

Construct an object representing an unknown type.

Parameters:
*argslist

Positional args.

**kwargsdict

Keyword args.

Returns:
object

The returned UnknownType object