Expected Behavior
Adding items to the container registry, though not typically used, should be supported for interactive sessions / sandbox testing.
Current Behavior
Adding an item to the container registry runs through this code path
if the class added was defined interactively, it may have a module name of __main__, which results in an empty string being stored as a module name. This results in the class being stored with a key like entry_name..TestClass
In general it's not suggested to do this, since without an importable module the class is transient, but it may be worth supporting this for notebook sessions
Possible Solution(s)
- Expand the documentation to dissuade people from doing this
- Use a separate code path for manual assignment vs entrypoint collection
- For manual additions, just use the provided name (to align setitem and getitem)
Steps to Reproduce (for bugs)
ipython
- define a test class:
class Test: ...
happi.containers.HappiRegistry()['ItemName'] = Test
- Examine keys
list(happi.containers.HappiRegistry().items()) = ('ItemName..Test', __main__.Test)
Context
Revealed in discussions with HZB about their use of happi
Your Environment
happi 2.4.0
Expected Behavior
Adding items to the container registry, though not typically used, should be supported for interactive sessions / sandbox testing.
Current Behavior
Adding an item to the container registry runs through this code path
if the class added was defined interactively, it may have a module name of
__main__, which results in an empty string being stored as a module name. This results in the class being stored with a key likeentry_name..TestClassIn general it's not suggested to do this, since without an importable module the class is transient, but it may be worth supporting this for notebook sessions
Possible Solution(s)
Steps to Reproduce (for bugs)
ipythonclass Test: ...happi.containers.HappiRegistry()['ItemName'] = Testlist(happi.containers.HappiRegistry().items()) = ('ItemName..Test', __main__.Test)Context
Revealed in discussions with HZB about their use of happi
Your Environment
happi 2.4.0