record_util.py

record_util.py#

Utility functions related to recording or execution metadata.

openmdao.utils.record_util.check_path(path, includes, excludes, include_all_path=False)[source]

Calculate whether path should be recorded.

Parameters:
pathstr

Path proposed to be recorded.

includeslist

List of things to be included in recording list.

excludeslist

List of things to be excluded from recording list.

include_all_pathbool

If set to True, will return True unless it is in excludes.

Returns:
bool

True if path should be recorded, False if it’s been excluded.

openmdao.utils.record_util.check_valid_sqlite3_db(filename)[source]

Raise an IOError if the given filename does not reference a valid SQLite3 database file.

Parameters:
filenamestr

The path to the file to be tested.

Raises:
IOError

If the given filename does not reference a valid SQLite3 database file.

openmdao.utils.record_util.create_local_meta(name)[source]

Create the metadata dictionary for this level of execution.

Parameters:
namestr

String to describe the current level of execution.

Returns:
dict

Dictionary containing the metadata.

openmdao.utils.record_util.deserialize(json_data, abs2meta, prom2abs, conns)[source]

Deserialize recorded data from a JSON formatted string.

If all data values are arrays then a numpy structured array will be returned, otherwise a dictionary mapping variable names to values will be returned.

Parameters:
json_datastr

JSON encoded data.

abs2metadict

Dictionary mapping absolute variable names to variable metadata.

prom2absdict

Dictionary mapping promoted input names to absolute. Needed to resolve auto_ivc outputs that are recorded with their promoted input name.

connsdict

Dictionary of all model connections.

Returns:
array or dict

Variable names and values parsed from the JSON string.

openmdao.utils.record_util.dict_to_structured_array(values)[source]

Convert a dict of variable names and values into a numpy structured array.

Parameters:
valuesdict

Dict of variable names and values.

Returns:
array

Numpy structured array containing the same names and values as the input values dict.

openmdao.utils.record_util.format_iteration_coordinate(coord, prefix=None)[source]

Format the iteration coordinate to a human-readable string.

Parameters:
coordlist

List containing the iteration coordinate.

prefixstr or None

Prefix to prepend to iteration coordinates.

Returns:
str

Iteration coordinate converted to a string.

openmdao.utils.record_util.get_source_system(iteration_coordinate)[source]

Get pathname of system that is the source of the iteration.

Parameters:
iteration_coordinatestr

The full unique identifier for this iteration.

Returns:
str

The pathname of the system that is the source of the iteration.

openmdao.utils.record_util.has_match(pattern, names)[source]

Determine whether pattern matches at least one name in names.

Parameters:
patternstr

The glob pattern to match.

nameslist

List of names to to check for a match.

Returns:
bool

True if there is a match.