Deregister_plugin breaks loading of the file


#1

Hi,
I’m trying to load plugins based on if UI is loaded or not
This is an example:

if not pyblish.api.registered_guis():
    pyblish.plugin.deregister_plugin(ValidateNegativeVolume)

I put this at the end of my module but for some reason debug info shows this message:
# DEBUG:pyblish.plugin:Ski
# pyblish.plugin : Skipped: “validate_model” (‘ValidateNegativeVolume’) #


#2

Hi @sega_m, what results are you expecting? How are you registering the plug-in? What do you do to get that message? What GUI is registered?


#3

Hi @marcus, i expect some plugins to skip validation when gui is not loaded
I register plugins by pyblish.plugin.register_plugin_path(“C:/pyblish_plugins”)
I’m using pyblish_qml gui


#4

Ah, the problem is you’re registering a path, and deregistering a plug-in.

If you want to deregister a path, you should use deregister_plugin_path and if you want to deregister a plug-in, you need to also register a plug-in with register_plugin.


#5

Thanks !
What if i will register plugins by both ways at the same time (e.g. i will add register_plugin at the end of the file ) will deregister_plugin work ? Or it still will load it by path ?


#6

Plug-ins from paths are discovered first, and then plug-ins registered explicitly, and there can’t be any duplicates.

If you need total control, you probably want to register plug-ins explicitly, and not paths.


#7

I found the way to register_plugins but i’m not sure that this is the best way
So what i did

import sys
sys.path.append("C:/pyblish_plugins")
import collect_instances, extract_scene, validate_model, validate_rig

And at the end of each file i added register_plugin method
Is it ok to do so ?


#8

Yes, that should work. Remember the plug-ins are the classes inside the modules.

You could try using this, plugins_from_module() to automate some of it. You can also pass a path to discover() which would return the contained plug-ins from all the files, and then register those.


#9

Thanks a lot,
Discover method works best for me:
pyblish.api.discover(paths=["C:/pyblish_plugins"])