Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add desvar_meta and constraint_meta to recorder metadata #669

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openmdao/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _setup(self):
rootmeta = root.unknowns.metadata(name)
if newitem is desvars:
rootmeta['is_desvar'] = True
rootmeta['desvar_meta'] = item[name]
if not rootmeta.get('_canset_', False):
raise RuntimeError("'%s' has been specified as a design "
"variable but that var is a component "
Expand All @@ -104,6 +105,7 @@ def _setup(self):
rootmeta['is_objective'] = True
if newitem is cons:
rootmeta['is_constraint'] = True
rootmeta['constraint_meta'] = item[name]

if MPI and 'src_indices' in rootmeta:
raise ValueError("'%s' is a distributed variable and may "
Expand Down
4 changes: 4 additions & 0 deletions openmdao/docs/usr-guide/tutorials/recording.rst
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,15 @@ The name of the SQLite table containing the derivatives is called `metadata`.
'top_promoted_name': 'p.f_xy',
'val': 0.0},
'p1.x': {'_canset_': True,
'desvar_meta': OrderedDict([('lower', -50.0), ('upper', 50.0), ('adder', 0.0), ('scaler', 1.0), ('size', 1)]),
'is_desvar': True,
'pathname': 'p1.x',
'shape': 1,
'size': 1,
'top_promoted_name': 'p1.x',
'val': 3.0},
'p2.y': {'_canset_': True,
'desvar_meta': OrderedDict([('lower', -50.0), ('upper', 50.0), ('adder', 0.0), ('scaler', 1.0), ('size', 1)]),
'is_desvar': True,
'pathname': 'p2.y',
'shape': 1,
Expand Down Expand Up @@ -610,13 +612,15 @@ This code prints out the following:
'top_promoted_name': 'p.f_xy',
'val': 0.0},
'p1.x': {'_canset_': True,
'desvar_meta': OrderedDict([('lower', -50.0), ('upper', 50.0), ('adder', 0.0), ('scaler', 1.0), ('size', 1)]),
'is_desvar': True,
'pathname': 'p1.x',
'shape': 1,
'size': 1,
'top_promoted_name': 'p1.x',
'val': 3.0},
'p2.y': {'_canset_': True,
'desvar_meta': OrderedDict([('lower', -50.0), ('upper', 50.0), ('adder', 0.0), ('scaler', 1.0), ('size', 1)]),
'is_desvar': True,
'pathname': 'p2.y',
'shape': 1,
Expand Down
9 changes: 7 additions & 2 deletions openmdao/recorders/hdf5_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ def record_metadata(self, group):
for grp, data in pairings:
for key, val in data:
meta_group = grp.create_group(key)

for mkey, mval in iteritems(val):
meta_group.create_dataset(mkey, data=mval)
if isinstance(mval, dict):
cgrp = meta_group.create_group(mkey)
for ckey, cval in iteritems(mval):
if cval:
cgrp.create_dataset(ckey, data=cval)
else:
meta_group.create_dataset(mkey, data=mval)
# if isinstance(val, (np.ndarray, Number)):
# grp.create_dataset(key, data=val)
# # TODO: Compression/Checksum?
Expand Down