Skip to content

Commit

Permalink
Added error message if a user tries to promote non existent inputs/ou…
Browse files Browse the repository at this point in the history
…tputs
  • Loading branch information
DKilkenny committed Oct 23, 2019
1 parent c89d6b2 commit a88e184
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openmdao/core/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,10 @@ def resolve(to_match, io_types, matches, proms):
pmap[name] = gname + name if gname else name

not_found = (set(names).union(renames).union(patterns)) - found
if self._var_promotes['any']:
if not self._var_abs2meta and isinstance(self, openmdao.core.group.Group):
raise RuntimeError('No inputs or outputs found. Check %s '
'to make sure it is not empty' % (self.msginfo))
if not_found:
if len(io_types) == 2:
call = 'promotes'
Expand Down
10 changes: 10 additions & 0 deletions openmdao/core/tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,16 @@ def test_promote_not_found3(self):
"ExecComp (C2): 'promotes' failed to find any matches for "
"the following names or patterns: ['xx'].")

def test_empty_group(self):
p = om.Problem()
g1 = p.model.add_subsystem('G1', om.Group(), promotes=['*'])

with self.assertRaises(Exception) as context:
p.setup()
self.assertEqual(str(context.exception),
"No inputs or outputs found. Check Group (G1) "
"to make sure it is not empty")

def test_missing_promote_var(self):
p = om.Problem()

Expand Down

0 comments on commit a88e184

Please sign in to comment.