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

NPE1Adapter Part 2 - adding the NPE1Adapter object. #125

Merged
merged 15 commits into from
Mar 23, 2022

Conversation

tlambert03
Copy link
Collaborator

@tlambert03 tlambert03 commented Mar 13, 2022

Breaking up #86 into three steps. This is part 2 (but it contains #124 which can be reviewed first)

This adds the NPE1Adapter itself, and makes the plugin manager aware of it.

  • in the discovery process, the _from_dist function now creates either a PluginManifest or an NPE1Shim based on the entry points offered by the plugin
  • NPE1Adapter is a subclass of PluginManifest that can lazily load contributions (when manifest.contributions is accessed), by calling manifest_from_npe1 which was updated in NPE1Adapter Part 1 - updated _from_npe1 conversion logic to prepare for locally defined objects #124
  • This lazily loaded manifest is used for the duration of the session, (caching behavior will be added in step 3)
  • The plugin manager itself now saves a list of _npe1_adapters during plugin discovery and gains a new method index_npe1_adapters that napari can use to force importing (or loading from cache) of all npe1 plugins.

Caching behavior comes in the next PR

@codecov
Copy link

codecov bot commented Mar 13, 2022

Codecov Report

Merging #125 (bc9c5b9) into main (cb45d7d) will increase coverage by 1.89%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##             main      #125      +/-   ##
===========================================
+ Coverage   98.10%   100.00%   +1.89%     
===========================================
  Files          24        25       +1     
  Lines        1581      1650      +69     
===========================================
+ Hits         1551      1650      +99     
+ Misses         30         0      -30     
Impacted Files Coverage Δ
npe2/_from_npe1.py 100.00% <100.00%> (+4.21%) ⬆️
npe2/_plugin_manager.py 100.00% <100.00%> (ø)
npe2/manifest/_npe1_adapter.py 100.00% <100.00%> (ø)
npe2/manifest/schema.py 100.00% <100.00%> (ø)
npe2/manifest/utils.py 100.00% <0.00%> (+12.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb45d7d...bc9c5b9. Read the comment docs.

@tlambert03 tlambert03 requested a review from nclack March 14, 2022 13:32
Copy link
Collaborator

@nclack nclack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. The docs in _from_npe1 are good. I thought a comment giving a bit of a high level introduction to what the shim was could go in _npe1_shim.py.

npe2/_plugin_manager.py Outdated Show resolved Hide resolved
npe2/manifest/_npe1_shim.py Outdated Show resolved Hide resolved
@tlambert03 tlambert03 changed the title NPE1Shim Part 2 - adding the NPE1 Shim object. NPE1Adapter Part 2 - adding the NPE1Adapter object. Mar 23, 2022
@tlambert03
Copy link
Collaborator Author

I thought a comment giving a bit of a high level introduction to what the shim was could go in _npe1_shim.py.

renamed to NPE1Adapter and added a longer docstring to NPE1Adapter explaining a bit more how it works.

@tlambert03 tlambert03 merged commit 39f00b9 into napari:main Mar 23, 2022
@tlambert03 tlambert03 deleted the shim2-shim branch March 23, 2022 22:14
@tlambert03 tlambert03 added the enhancement New feature or request label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants