Skip to content
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

Raise when detecting multiple matching entry points #5530

Closed
ltalirz opened this issue May 20, 2022 · 3 comments · Fixed by #5531
Closed

Raise when detecting multiple matching entry points #5530

ltalirz opened this issue May 20, 2022 · 3 comments · Fixed by #5531
Assignees
Labels
Milestone

Comments

@ltalirz
Copy link
Member

ltalirz commented May 20, 2022

Describe the bug

Due to a slight misunderstanding of the new importlib.metadata API, AiiDA did no longer raise when detecting multiple entries for a given entry point (pair of group + name), and instead simply loaded the first one.

Will open PR to fix

@ltalirz
Copy link
Member Author

ltalirz commented May 20, 2022

While our code clearly intends to do this check (and probably was doing it before we switched to the new importlib.metadata API), I now notice that reintroducing it creates problems e.g. in the AiiDAlab environment, where users may want to e.g. install a newer AiiDA version over the one that is shipped with the image (and which they can't remove).

E.g. after installing a separate AiiDA version in the user's local environment in the AiiDAlab docker image (my AiiDA 2.0 version), opening the verdi shell gives me

ValueError: aiida.groups:core is not a valid entry point string: Multiple entry points 'core' found in group 'aiida.groups': [EntryPoint(name='core', value='aiida.orm.groups:Group', group='aiida.groups'), EntryPoint(name='core', value='aiida.orm.groups:Group', group='aiida.groups')]

I'm a little surprised that this did not surface before... it's true that we started using entry points in more places in aiida-core recently, but we were using them also before.

In my view it needs to be possible to install AiiDA over an existing installation.

One thing we could do is: if multiple entries are discovered, check whether their values (target strings) are the same.
If they are, then it actually does not matter which one we load and we can proceed.
If their values differ, we don't know what to do and raise.

I will add this to the PR now.

@csadorf @sphuber thoughts welcome

@chrisjsewell
Copy link
Member

Are you sure you are not misunderstanding the difference between importlib.metadata and importlib_metadata, the latter of which implements the new python 3.10 API

@ltalirz
Copy link
Member Author

ltalirz commented May 20, 2022

Are you sure you are not misunderstanding the difference between importlib.metadata and importlib_metadata, the latter of which implements the new python 3.10 API

What would make you think that?
Have you looked at the code example in the PR?

@sphuber sphuber added this to the v2.1 milestone May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants