-
Notifications
You must be signed in to change notification settings - Fork 337
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
Extension plugins #1040
Extension plugins #1040
Conversation
Hey David, I really like this. Some thoughts:
Thoughts? |
Hey, i also really like this. I do agree with Allan's points. Also i wonder, as discussed before things like rez-pip might (should?) become separate projects, would this be the mechanism to install them? |
Absolutely my thoughts Thorsten yes, rez-pip should be a separate project
and yes should be installed as an extension. Downside being that 'rez pip'
exists but 'rez-pip' doesn't, however that's something that rez-install-ext
would be able to fix, which is another reason for having it.
…On Tue, Mar 16, 2021 at 9:55 AM Thorsten Kaufmann ***@***.***> wrote:
Hey,
i also really like this. I do agree with Allan's points. Also i wonder, as
discussed before things like rez-pip might (should?) become separate
projects, would this be the mechanism to install them?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSW67HOXOS4L32IMZCLTD2F57ANCNFSM4ZC4XSLQ>
.
|
Great stuff. I am totally in love with the idea of a more modular Rez and an ecosystem of extensions that you can use if you have a use case (think other package managers like nuget, chocolate or vcpkg or the likes on windows)! @davidlatwe what do you think about the changes Allan suggested? |
Yeah it needs to happen. Rez is already more monolithic than I'd like,
modularity ftw.
A
…On Tue, Mar 16, 2021 at 10:17 AM Thorsten Kaufmann ***@***.***> wrote:
Great stuff. I am totally in love with the idea of a more modular Rez and
an ecosystem of extensions that you can use if you have a use case (think
other package managers like nuget, chocolate or vcpkg or the likes on
windows)!
@davidlatwe <https://github.com/davidlatwe> what do you think about the
changes Allan suggested?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSTMA2IE64U25DNMJJLTD2IPXANCNFSM4ZC4XSLQ>
.
|
Just by chance I ran into this today, illustrating my point about an Application class: #1033 |
Thanks @nerdvegas and @instinct-vfx !! About naming, I agree we should avoid using the term "Application" for this, but not so sure about using "Extension" for that plugin type instead. Renaming the config entry "plugin_module" into "extensions" make sense to me as well, since the plugin manager can load all types of plugin from there. With this in mind, naming the new type of plugin to "Extension" makes me think the config "extensions" can only use to load that specific plugin type. Maybe "Supplement" or "Add-on" would be better name for new plugin type ? I will push the commit that reflect the points above first, and rename again if my point make sense to you guys as well. About additional "rez-install-ext" tool, I was hoping that if we could just use venv's |
Hey I don't quite follow... do you mean that you're thinking ahead to where all plugins are loaded this way, and that 'plugin_modules' would encompass all plugin types, not just extensions? In any case that brings up another point.. it'd be great if that config entry were not necessary at all tbh. It's an odd extra step - with most tools, installing a new plugin is all you need to do, the system then knows about it. It'd be good if we could do the same. Wrt rez-install-ext. I would not even want the user to have to run What if then, we start thinking about a new plugin architecture at the same time; and we think about how to ditch the config setting. We could have this:
? ps - one way we might track installed plugins is to iterate over all visible modules and expect certain standard attributes (rez_plugin_type, rez_plugin_name for eg) that identify them as rez plugins. |
No, not thinking ahead, it already does that. Since the current "extension" layout like what I have in my example rezbefoo, the
That would be awesome :D
I'll have a few more tests on #1039 since I thought this might still a bit related, e.g. to use |
Oh right, apologies for my misunderstanding. So is this compatible with
existing plugin types? Ie if I have an old-style plugin (found via
'plugin_path') and a new one, will they both function correctly and both
appear in the list shown by `rez -i`?
In terms of avoiding the config setting and just detecting plugins
automatically, that should be doable I think. We'd just use
`pkgutil.iter_modules` and find those modules with a `rezplugins` submodule.
…On Tue, Mar 16, 2021 at 2:18 PM David Lai ***@***.***> wrote:
do you mean that you're thinking ahead to where all plugins are loaded
this way, and that 'plugin_modules' would encompass all plugin types, not
just extensions?
No, not thinking ahead, it already does that. Since the current
"extension" layout like what I have in my example rezbefoo
<https://github.com/davidlatwe/rezbefoo>, the rezplugins is a sub-module
of rezbefoo, so whatever plugin type it contains, will get loaded from
the "plugin_modules".
we don't have to update a config setting; rez-install-plugin tracks this
itself
That would be awesome :D
as well as supporting "rez foo" extension form, we also support "rez-foo".
Rez-install-plugin takes care of this
I'll have a few more tests on #1039
<#1039> since I thought this might
still a bit related, e.g. to use entry_points or not in the setup.py.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSW5LQQKU5F5VZEWLJ3TD3E2DANCNFSM4ZC4XSLQ>
.
|
No worries ! And yes, old-style plugin that found via "plugin_path" can live with new that found via "plugin_modules" (renamed into "extensions" at this point), and all listed by Here's the pseudo code of current plugin loading implementation: # in plugin_managers.py
def extend_path(path, name):
"""Extend a package's path."""
def append_if_valid(dir_):
# do some check before appending
path.append(subdir)
for dir_ in config.plugin_path: # old-style
append_if_valid(dir_)
for name in config.extensions: # new-style
# try load the module
module_path = sys.modules[name].__path__
for dir_ in module_path:
append_if_valid(dir_) |
Ok coooool. Giving the existing interoperability then, I reckon dropping
the config setting is a must (because old-style plugins don't require doing
this, so neither should new-style ones!) However I _ think_ the module
iteration approach suggested should do the trick.
Looking forward to seeing this wrapped up, I've been wanting to rework
plugins for a while now. And when we add rez-install-plugin, we'll have a
bonafide way to support plugins that can be implemented as separate,
standard pip packages. Lovely. When we get there, it'd be great to have an
example installable plugin as well. Maybe we add an examples/ dir, move
that example_packages/ dir into it, and add sometihng like
examples/plugins/foo.
Thx
A
…On Tue, Mar 16, 2021 at 2:44 PM David Lai ***@***.***> wrote:
No worries ! And yes, old-style plugin that found via "plugin_path" can
live with new that found via "plugin_modules" (renamed into "extensions" at
this point), and all listed by rez -i 🥳
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSQGYTU2I5QQH4QZX23TD3HYJANCNFSM4ZC4XSLQ>
.
|
Sorry, just to be sure. :P |
Yep. Basically these new-type plugins need to be automatically detected,
because that's already the case for old-style plugins.
Another thought - once we also have an example plugin in the repo, we could
use this in a new plugin.yaml github workflow to test that plugin
installation works.
Incidentally, I'm currently working on a workflow to automatically run the
benchmarking suite on every release, and keep an historic list in the repo.
Cheers
A
…On Tue, Mar 16, 2021 at 3:01 PM David Lai ***@***.***> wrote:
I reckon dropping the config setting is a must (because old-style plugins
don't require doing this, so neither should new-style ones!)
Sorry, just to be sure. :P
Are you saying that to drop new config setting "plugin_module" and replace
it with module iteration approach or maybe other, as long as no additional
setting required ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSSGJBADZ6GTPG3KZMDTD3J3BANCNFSM4ZC4XSLQ>
.
|
:O Anyway, I'll get started :D |
Mm well, I suppose you do end up with a path per plugin so I guess you are
explicitly listing them. In any case, not having to would be great. Let's
see if it's doable.
…On Tue, Mar 16, 2021 at 3:22 PM David Lai ***@***.***> wrote:
because that's already the case for old-style plugins.
:O
I didn't know about this, I thought the only way to load them is from
"pluing_path" config setting !
Anyway, I'll get started :D
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSWQD6KWE4OZRPXPZ3LTD3MJTANCNFSM4ZC4XSLQ>
.
|
Ah no, we won't need that MAIN file in every plugin root, only the main Test failed on latest commit. Looks like there's something wrong with the test data, seems the material that required for the new tests were not being installed and leads to failed test. Will investigate this later. |
Okay, that's it. |
Top comment of this PR has been updated to reflect changes. |
Hey David, cheers! I will get to this, but bear in mind I have an FMX talk coming up and it may be derailed by that for a bit as I'll have to spend time over a few weeks prepping for it. A couple of thoughts (no need to act on these now! It's so I don't forget):
|
# Conflicts: # src/rez/data/tests/extensions/bar/__init__.py # src/rez/data/tests/extensions/bar/rezplugins/__init__.py # src/rez/data/tests/extensions/bar/rezplugins/package_repository/__init__.py # src/rez/data/tests/extensions/bar/rezplugins/package_repository/memory.py # src/rez/data/tests/extensions/foo/__init__.py # src/rez/data/tests/extensions/foo/rezplugins/__init__.py # src/rez/data/tests/extensions/foo/rezplugins/package_repository/__init__.py # src/rez/data/tests/extensions/foo/rezplugins/package_repository/cloud.py # src/rez/data/tests/extensions/non-mod/rezplugins/__init__.py # src/rez/data/tests/extensions/non-mod/rezplugins/package_repository/__init__.py # src/rez/data/tests/extensions/non-mod/rezplugins/package_repository/memory.py
I just want to jump in to say, awesome work here so far @davidlatwe . |
Hey I'm just looking at this now and I see an issue. Currently, the plugin manager searches all packages in sys.path and will assume its found a plugin type if it finds a subdir in the package with matching name (eg "build_system"). There are two problems with this though:
To that end, how about we mandate that a |
I have thought about this earlier before, and was considering using python package's But adding |
Reading Allan's comment i was actually going to suggest using entry_points. They seem very well suited for this task and are specifically designed to support plugin-like discovery mechanisms. I would actually prefer that route. |
But with Oh, but |
Could you elaborate on the last one? Why would it not work if Rez is a rez package? PYTHONPATH is a good point hm. |
Sorry, that was wrong. It doesn't matter if Rez is as a rez package or not, but which Python is being used. Because that will affect where the python package metadata will be looked for entry points, correct ? But if it's using |
Oh yeah you may be right. Since entry points are specific to python's own
packaging ecosystem, it's gonna be more difficult to manage this in
rezified packages (eg if you wanna use rez API + plugins within a resolved
env).
…On Tue, 1 Jun. 2021, 18:04 David Lai, ***@***.***> wrote:
Sorry, that was wrong. It doesn't matter if Rez is as a rez package or
not, but which Python is being used. Because that will affect where the
python package metadata will be looked for entry points, correct ?
But if it's using __rez__.py then as long as it can be found in sys.path,
it can be loaded.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSWTLZHKPSJ5DT4J4FTTQSIBJANCNFSM4ZC4XSLQ>
.
|
That makes sense. |
Just re-read the comment and,
I found that isn't entirely true, there still need So, I will just adding |
You're right, I missed this. Sound good.
…On Mon, 7 Jun. 2021, 14:58 David Lai, ***@***.***> wrote:
Just re-read the comment and,
Currently, the plugin manager searches all packages in sys.path and will
assume its found a plugin type if it finds a subdir in the package with
matching name (eg "build_system").
I found that isn't entirely true, there still need rezplugins namespace
on top of build_system for rez to include the module. But the current
implementation indeed wasting search time on packages that are obviously
has nothing to do with rez.
So, I will just adding rezplugins folder existence check for now, since I
think it works the same as __rez__.py.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1040 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSS7SPFMYYKJIDH7H7LTRRGYDANCNFSM4ZC4XSLQ>
.
|
Feature Propose
Allowing people registering their own sub-command, forwarding function, configs.
What's Added (updated)
sys.path
for module that hasrezplugins
sub-moduleWhy scan modules for plugins ?
The new command type plugin enables registering custom sub-command, which may need to access additional module to do it's job. Hence we have to install the module which is required by the sub-command into Rez's venv, so that it could be imported in production installed Rez session which is ignoring
PYTHONPATH
. With these in mind, installing custom rezplugins as a sub-module would be the most desirable way. Now, how to let Rez register plugin that has been installed intolib/site-packages
? Instead of registering full path intorezconfig.plugin_path
, simply scan modules fromsys.path
is most friendly.Note
When name clashing happen, plugins loaded by the new loading mechanism will take precedence over plugins that are registered in
rezconfig.plugin_path
.Please have a visit to my example plugin and have a look how this works 👉🏼 https://github.com/davidlatwe/rezbefoo(outdated)