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

Reworked error/warning behavior for set_input_defaults. #1568

Merged
merged 7 commits into from
Jul 28, 2020

Conversation

naylor-b
Copy link
Member

Summary

Ambiguity resolution now happens at the top level only. Ambiguities that are resolved at a higher level are now warnings instead of errors. A warning is issued if a higher level call to set_input_defaults has a missing metadata entry that is supplied from a lower level.

Related Issues

Backwards incompatibilities

None

New Dependencies

None

…t is between a higher level call and a lower level one.
…ry ambiguity errors/warnings at any level in the system tree as long as the ambiguity was ultimately fixed at a higher level.
@project-bot project-bot bot added this to In progress in OpenMDAO Dev [Read only] Jul 24, 2020
@@ -2198,14 +2199,14 @@ def test_conflicting_units(self):
with self.assertRaises(Exception) as cm:
p.setup()

self.assertEqual(cm.exception.args[0], "Groups 'par.G4' and 'par.G5' added the input 'x' with conflicting 'units'.")
self.assertEqual(cm.exception.args[0], "Group (<model>): The subsystems G1.G2 and par.G4 called set_input_defaults for promoted input 'x' with conflicting values for 'units'. Call <group>.set_input_defaults('x', units=?), where <group> is the Group named '' to remove the ambiguity.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have special handling for the top level group...
It seems like this message would make more sense to the user if it referred to "the 'model'" instead of "the group named ''", since that's how the user would reference it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed "Group named ''" to "model"

@@ -53,6 +53,10 @@ class Group(System):
Dictionary of input_name: (output_name, src_indices) connections.
_group_inputs : dict
Mapping of promoted names to certain metadata (src_indices, units).
_static_group_inputs : dict
Group inputs added outside of setup/configure.
_post_setup_group_inputs : dict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name confuses me a little. At first, I thought it meant after the user calls prob.setup. At second, I thought that configure is technically "post setup" too. Maybe pre_configure is better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -53,6 +53,10 @@ class Group(System):
Dictionary of input_name: (output_name, src_indices) connections.
_group_inputs : dict
Mapping of promoted names to certain metadata (src_indices, units).
_static_group_inputs : dict
Group inputs added outside of setup/configure.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where else can we add inputs? Does this just mean after prob.setup?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static means everything outside of system setup and configure. If things are added in setup/configure they're considered 'dynamic' and they get blown away if problem setup is called again. Static stuff is never removed.

Copy link
Contributor

@swryan swryan Jul 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a nice comment to put in the code somewhere
More helpful I think that what's there for the definition of static mode:

    _static_mode : bool
        If true, we are outside of setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated comment

group_inputs.extend(ginputs)
if rank != myrank:
for p, mlist in ginputs.items():
self._group_inputs[p].extend(mlist)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug fix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data structure was changed to make error checking easier later.

origin_prom = submeta['prom']
if origin != top_origin:
simple_warning(f"Group '{top_origin}' did not set a default "
f"'{key}' for input '{top_prom}', so the value of "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a test for this warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now. :)

OpenMDAO Dev [Read only] automation moved this from In progress to Reviewer approved Jul 28, 2020
@swryan swryan merged commit 00da97d into OpenMDAO:master Jul 28, 2020
OpenMDAO Dev [Read only] automation moved this from Reviewer approved to Done Jul 28, 2020
@naylor-b naylor-b deleted the group_input_warning branch March 8, 2022 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Change error in the event of conflicting metadata entries in multiple set_input_defaults calls to a warning.
3 participants