-
Notifications
You must be signed in to change notification settings - Fork 29
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
Importing containers can result in conflicts during entry point containercollection #279
Comments
I gave this a bit more thought there are a couple ways you could resolve the initial problem without changes to happi:
A broader question would be: "is it OK to have aliases to containers?" |
Thoughts, @tangkong? |
I totally thought I left a comment here whoops I think 1 is acceptable, and is probably the simplest solution. It will be an additional thing to communicate/document, since it's not obvious that you can't just import the class you need to inherit from it. (Every package in the future that wants to expose inheritable containers will have to do this) Could we change how we handle collisions? The first thought is to just ignore the duplicate entry, but I'm not sure if the order packages are collected in is consistent, which might make the key indeterminate. We could set up some logic (take the name that's first in alphabetical order?) to make it consistent I guess. I agree that aliases to containers (several keys to the same container) will lead to confusion I think on balance we can probably go with 1 in the short term, and is probably what we should do until we find a more elegant solution (if there is one) |
My take on it - which still could be potentially flawed: The order of loading is likely inconsistent and not necessarily what we would hope: so we can't rely on it. Because we can't rely on it, we can't know if "pcdsdevices.LightPathItem" is the canonical one or "lightpath.LightpathItem" is the canonical one. You could maybe argue that maybe we should check the module it came from and use that one - but what if we see the pcdsdevices entrypoint before we see lightpath: that gets registered and then we overwrite it with the lightpath one? It's rather confusing. I think my suggestion (2) above is a reasonable way around this scenario, though I like it less because it makes exporting containers a bit more labor-intensive. So then the guidance for users who import other containers would be (summarizing from the above):
|
Agreed on all points. I'm coming to terms with (1) being simple enough as long as people read the documentation we write. 😬 |
Description
Following the discussions below, this is now a documentation issue. We should describe to users how to import containers from other packages without encountering the entry point conflict.
In short, if you wanted to use
package.happi.containers.MyContainer
in another package, you should do something similar to:Context
The conflict shows itself as:
When you import
from lightpath.happi.containers import LightpathItem
inpcdsdevices.happi.containers
It seems the container gets collected once in lightpath and again in pcdsdevices under different keys, since they're being collected from different entrypoints. I can add an issue for it
Originally posted by @tangkong in pcdshub/lightpath#133 (comment)
The text was updated successfully, but these errors were encountered: