pythonopenmdao

KeyError when instantiating Birkhoff transcription in Dymos


I'm getting a KeyError when I try to use the Birkhoff transcription. Running

import dymos as dm
tx = dm.Birkhoff(num_nodes=5)

results in the error below. Looking at a recent issue on Github, I have a hunch it's related to the version of OpenMDAO? I'm using dymos version 1.10.0 and openmdao version 3.34.2. If this is the case, what version of openmdao should I be using for the Birkhoff transcriptions? If not, any idea what's going on here? Thanks!

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/openmdao/utils/options_dictionary.py:514, in OptionsDictionary.__setitem__(self, name, value)
    513 try:
--> 514     meta = self._dict[name]
    515 except KeyError:
    516     # The key must not have been declared.

KeyError: 'num_nodes'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
Cell In[2], line 1
----> 1 dm.Birkhoff(num_nodes=5)

File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/dymos/transcriptions/pseudospectral/birkhoff.py:30, in Birkhoff.__init__(self, **kwargs)
     29 def __init__(self, **kwargs):
---> 30     super(Birkhoff, self).__init__(**kwargs)
     31     self._rhs_source = 'ode_iter_group.ode_all'

File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/dymos/transcriptions/transcription_base.py:46, in TranscriptionBase.__init__(self, **kwargs)
     44 self._declare_options()
     45 self.initialize()
---> 46 self.options.update(kwargs)
     47 self.init_grid()
     49 # Where to query var info.

File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/openmdao/utils/options_dictionary.py:473, in OptionsDictionary.update(self, in_dict)
    464 """
    465 Update the internal dictionary with the given one.
    466
   (...)
    470     The incoming dictionary to add to the internal one.
    471 """
    472 for name in in_dict:
--> 473     self[name] = in_dict[name]

File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/openmdao/utils/options_dictionary.py:517, in OptionsDictionary.__setitem__(self, name, value)
    514     meta = self._dict[name]
    515 except KeyError:
    516     # The key must not have been declared.
--> 517     self._raise(f"Option '{name}' cannot be set because it has not been declared.",
    518                 exc_type=KeyError)
    520 if self._read_only:
    521     self._raise(f"Tried to set read-only option '{name}'.", exc_type=KeyError)

File ~/miniconda3/envs/cp2/lib/python3.11/site-packages/openmdao/utils/options_dictionary.py:245, in OptionsDictionary._raise(self, msg, exc_type)
    243 else:
    244     full_msg = '{}: {}'.format(self._parent_name, msg)
--> 245 raise exc_type(full_msg)

KeyError: "Option 'num_nodes' cannot be set because it has not been declared."

Solution

  • This is due to the latest documentation matching the master branch on github and not the latest release. You can pip install from github to access the latest version, or wait a few days as we're in the process of getting a new release out (that matches the docs).