Pyblish plugins doesnt get removed from GUI after pyblish.api.deregister_all_plugins()

Hi all.

In my script i use:

pyblish.api.deregister_all_paths()
pyblish.api.deregister_all_plugins()
print "1", pyblish.api.registered_paths()
print "2", pyblish.api.registered_plugins()

to clear previously used scripts and to confirm deregistration.

Then i register new ones with

register_plugins(docstring_families)
print "3", pyblish.api.registered_paths()
print "4", pyblish.api.registered_plugins()

I register plugins after what families I’ve written in the plugin classes docstring and in register_plugins i use pyblish.api.register_plugin(obj) only…
Then i show the gui, pyblish_lite.

So far everything works but when i run this script again but with different plugins the previous plugins will also show up in the GUI, together with the new plugins.
Calling

print pyblish.api.registered_plugins()
print pyblish.api.registered_paths()

after deregistration shows that the old plugins are gone and calling

print pyblish.api.registered_plugins()
print pyblish.api.registered_paths()

after registering the new plugins shows that only the new plugins are registered.
Then i proceed to show pyblish lite and there the new and old plugins show up.

Any ideas?

Thanks!

Hi @hamaro,

Thanks for reporting this! Some questions…

What is this command? Do you mean this?

from pyblish import api
api.register_plugin(docstring_families)

If so, what is docstring_families? That command takes a single plug-in as argument.

Sorry I’m not sure what you mean here.

Are you able to post something I can reproduce on my end?

To find out how pyblish_lite discovers plug-ins, you can find the source here.

register_plugins(docstring_families)
Looks like this, where pluginList contains full length paths to plugin .py files
I guess nevermind what i wrote about families, they get turned out into the paths that go into pluginList :slight_smile:
import imp
def register_plugins(families):

#register the plugins
for pluginfile in pluginList:
    module = imp.load_source('module.name', pluginfile)
    for name, obj in inspect.getmembers(module):
        if inspect.isclass(obj):
            try:
                pyblish.api.register_plugin(obj)
            except:
                pass

I can’t tell what’s happening there. imp.load_source is effectively what api.discover() does to registered plug-in paths already. Why not register their parent directory?

Maybe if you posted something I could run on my end that demonstrates the problem it would be easier to help.

It’s a long-shot, but somewhat related and potentially useful to your case; have you seen the latest feature on filtering the discovery of plug-ins that got added a few days ago?

from pyblish import api


class ExcludeMe(api.ContextPlugin):
    order = api.CollectorOrder


class ChangeMe(api.InstancePlugin):
    order = api.ValidatorOrder
    optional = False


def my_filter(plugins):
    for plugin in plugins[:]:  # use [:] to avoid editing whilst looping

        # Plug-ins can be removed..
        if plugin.__name__ not in ("ChangeMe",):
            plugins.remove(plugin)

        # ..and modified
        if plugin.__name__ == "ChangeMe":
            plugin.optional = True


api.register_plugin(ExcludeMe)
api.register_plugin(ChangeMe)
api.register_discovery_filter(my_filter)

plugins = api.discover()

assert len(plugins) == 1
assert plugins[0] is ChangeMe
assert ChangeMe.optional is True

api.deregister_discovery_filter(my_filter)

Hey Marcus, there was an error on my side.
False alarm, sorry.

Thanks for your suggestions!

1 Like