Skip to content
New issue

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

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

Already on GitHub? # to your account

BUG: Manually adding a container without a module to the registry gives malformed name #341

Open
tangkong opened this issue Nov 14, 2023 · 0 comments

Comments

@tangkong
Copy link
Contributor

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)

  1. ipython
  2. define a test class: class Test: ...
  3. happi.containers.HappiRegistry()['ItemName'] = Test
  4. 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant