sqlite_recorder.py#

Class definition for SqliteRecorder, which provides dictionary backed by SQLite.

class openmdao.recorders.sqlite_recorder.SqliteRecorder(filepath, append=False, pickle_version=4, record_viewer_data=True)[source]

Bases: CaseRecorder

Recorder that saves cases in a sqlite db.

Parameters:
filepathstr

Path to the recorder file.

appendbool, optional

Optional. If True, append to an existing case recorder file.

pickle_versionint, optional

The pickle protocol version to use when pickling metadata.

record_viewer_databool, optional

If True, record data needed for visualization.

Attributes:
_record_viewer_databool

Flag indicating whether to record data needed to generate N2 diagram.

connectionsqlite connection object

Connection to the sqlite3 database.

metadata_connectionsqlite connection object

Connection to the sqlite3 database, if metadata is recorded separately.

_record_metadataWhether this process is recording metadata. Always True

for serial runs, only True for rank 0 of parallel runs.

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

Dictionary mapping absolute names to promoted names.

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

Dictionary mapping promoted names to absolute names.

_abs2meta{‘name’: {}}

Dictionary mapping absolute variable names to their metadata including units, bounds, and scaling.

_pickle_versionint

The pickle protocol version to use when pickling metadata.

_filepathstr

Path to the recorder file.

_database_initializedbool

Flag indicating whether or not the database has been initialized.

_startedset

set of recording requesters for which this recorder has been started.

__init__(filepath, append=False, pickle_version=4, record_viewer_data=True)[source]

Initialize the SqliteRecorder.

delete_recordings()[source]

Delete all the recordings.

property parallel

Return True if this recorder is recording on multiple processes.

record_derivatives(recording_requester, data, metadata, **kwargs)

Route the record_derivatives call to the proper method.

Parameters:
recording_requesterobject

System, Solver, Driver in need of recording.

datadict

Dictionary containing derivatives keyed by ‘of,wrt’ to be recorded.

metadatadict

Dictionary containing execution metadata.

**kwargskeyword args

Some implementations of record_derivatives need additional args.

record_derivatives_driver(recording_requester, data, metadata)[source]

Record derivatives data from a Driver.

Parameters:
recording_requesterobject

Driver in need of recording.

datadict

Dictionary containing derivatives keyed by ‘of,wrt’ to be recorded.

metadatadict

Dictionary containing execution metadata.

record_iteration(recording_requester, data, metadata, **kwargs)

Route the record_iteration call to the proper method.

Parameters:
recording_requesterobject

System, Solver, Driver in need of recording.

datadict

Dictionary containing desvars, objectives, constraints, responses, and System vars.

metadatadict, optional

Dictionary containing execution metadata.

**kwargskeyword args

Some implementations of record_iteration need additional args.

record_iteration_driver(driver, data, metadata)[source]

Record data and metadata from a Driver.

Parameters:
driverDriver

Driver in need of recording.

datadict

Dictionary containing desvars, objectives, constraints, responses, and System vars.

metadatadict

Dictionary containing execution metadata.

record_iteration_problem(problem, data, metadata)[source]

Record data and metadata from a Problem.

Parameters:
problemProblem

Problem in need of recording.

datadict

Dictionary containing desvars, objectives, and constraints.

metadatadict

Dictionary containing execution metadata.

record_iteration_solver(solver, data, metadata)[source]

Record data and metadata from a Solver.

Parameters:
solverSolver

Solver in need of recording.

datadict

Dictionary containing outputs, residuals, and errors.

metadatadict

Dictionary containing execution metadata.

record_iteration_system(system, data, metadata)[source]

Record data and metadata from a System.

Parameters:
systemSystem

System in need of recording.

datadict

Dictionary containing inputs, outputs, and residuals.

metadatadict

Dictionary containing execution metadata.

record_metadata_solver(solver, run_number=None)[source]

Record solver metadata.

Parameters:
solverSolver

The Solver for which to record metadata.

run_numberint or None

Number indicating which run the metadata is associated with. None for the first run, 1 for the second, etc.

record_metadata_system(system, run_number=None)[source]

Record system metadata.

Parameters:
systemSystem

The System for which to record metadata.

run_numberint or None

Number indicating which run the metadata is associated with. None for the first run, 1 for the second, etc.

property record_on_process

Determine if recording should be performed on this process.

record_viewer_data(model_viewer_data, key='Driver')[source]

Record model viewer data.

Parameters:
model_viewer_datadict

Data required to visualize the model.

keystr, optional

The unique ID to use for this data in the table.

shutdown()[source]

Shut down the recorder.

startup(recording_requester, comm=None)[source]

Prepare for a new run and create/update the abs2prom and prom2abs variables.

Parameters:
recording_requesterobject

Object to which this recorder is attached.

commMPI.Comm or <FakeComm> or None

The MPI communicator for the recorder (should be the comm for the Problem).

openmdao.recorders.sqlite_recorder.array_to_blob(array)[source]

Make numpy array into a BLOB.

Convert a numpy array to something that can be written to a BLOB field in sqlite.

TODO : move this to a util file?

Parameters:
arrayarray

The array that will be converted to a blob.

Returns:
blob

The blob created from the array.

openmdao.recorders.sqlite_recorder.blob_to_array(blob)[source]

Convert sqlite BLOB to numpy array.

TODO : move this to a util file?

Parameters:
blobblob

The blob that will be converted to an array.

Returns:
array

The array created from the blob.