-
Notifications
You must be signed in to change notification settings - Fork 50
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
Setup pluggy with locking plugin #965
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for conda-store canceled.
|
✅ Deploy Preview for conda-store canceled.
|
0309540
to
8ebc697
Compare
import uuid | ||
|
||
|
||
class PluginContext: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly a copy/paste from the ActionContext
self.conda_flags = conda_flags | ||
|
||
@hookspec.hookimpl | ||
def lock_environment( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly a copy/paste from the solve_lockfile_action
settings = self.get_settings(db) | ||
|
||
# Load lock plugin | ||
self.load_plugin_by_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently loading the lock plugin globally by it's name. In the future, when more lock plugins are available, this should be configurable. See the pluggy demo for more examples of how this can be done.
|
||
def collect_plugins(self): | ||
"""Registers all availble plugins with the plugin registry""" | ||
for plugin in BUILTIN_PLUGINS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, there is only one builtin plugin. As we add more, we'll want to register them here. And we'll probably also want to support loading user defined/installed plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, let's add a TODO
here to add entry point based collection like https://github.com/conda/conda/blob/cf3a0fa9ce01ada7a4a0c934e17be44b94d4eb91/conda/plugins/manager.py#L131
2cc11d8
to
fc992ff
Compare
conda-store-server/conda_store_server/plugins/plugin_registry.py
Outdated
Show resolved
Hide resolved
conda-store-server/conda_store_server/plugins/plugin_context.py
Outdated
Show resolved
Hide resolved
conda-store-server/conda_store_server/plugins/plugin_context.py
Outdated
Show resolved
Hide resolved
self.conda_flags = conda_flags | ||
|
||
@utils.run_in_tempdir | ||
@hookspec.hookimpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I was expecting the implementations to live in a different abstraction level, not so close to the actual code. For reference, this is how conda does it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @soapy1! I like what I'm seeing, but I'm wondering if we could leverage some "community knowledge" and steal what conda is doing for their hooks. They have one more layer in between the plugin and the hook, and the best part if that they have documented it veeery well. Do you think you can take a look at their setup and see what things we could benefit from? 🙏
1794bcd
to
d1f3549
Compare
@jaimergp I still have more work to do with docs + tests, but wondering if you could take a gander to see if this is more the implementation you were thinking. Thanks! |
Yep, I only took a quick look, but that's more aligned with what I had in mind! |
Fixes #929
Description
This set's up conda-lock to be run as a plugin. By running the locking functionality as a plugin, opposed to a builtin action, we will be able to more easily swap out locking implementations. This is helpful for developer experimentation and providing users with another way of customize their conda-store install.
Some things that this PR adds:
For a more complete demo of how this approach can be extended, see main...soapy1:conda-store:plugin-demo-pluggy. For a more complete description of what is added by this demo see the conversation in GH.
Next steps
fast follow pr's
opportunities to extend the use of plugins
Pull request checklist