Skip to content

Importing containers can result in conflicts during entry point containercollection #279

@tangkong

Description

@tangkong

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:

import package.happi.containers

class NewContainer(package.happi.containers.MyContainer):
    pass

Context

The conflict shows itself as:

(pcds-5.4.1)roberttk@psbuild-rhel7-01:~/devrepos/pcdsdevices(enh_lp_mixin +)$ happi container-registry
File "/cds/home/r/roberttk/devrepos/happi/happi/containers.py", line 208, in load
    self._safe_add(entry_name, var)
  File "/cds/home/r/roberttk/devrepos/happi/happi/containers.py", line 173, in _safe_add
    raise RuntimeError(f"Duplicated entry found. Keys: {key} "
RuntimeError: Duplicated entry found. Keys: pcdsdevices.happi.containers.LightpathItem and lightpath.happi.containers.LightpathItem point to same class: <class 'lightpath.happi.containers.LightpathItem'>

When you import from lightpath.happi.containers import LightpathItem in pcdsdevices.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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions