pyblish / pyblish-qml

Pyblish QML frontend for Maya 2013+, Houdini 11+, Nuke 8+ and more
GNU Lesser General Public License v3.0
114 stars 44 forks source link

instance.data['publish'] doesn't work like it should #375

Open guruBry opened 1 year ago

guruBry commented 1 year ago

It seems like the "publish" value on an instance doesn't behave correctly, with families

If you set the 'publish' key on an instance's data to False, it will show up in the context list as toggled off, which is expected. However if you manually enable it, then try to Validate, validation doesn't process on the newly-enabled instance.

But if you enable the "publish" key to True from the beginning, the Validate process will act on the instance.

import pyblish.api

class TestPlugin(pyblish.api.ContextPlugin):
    label = "Add Test Instance"
    order = pyblish.api.CollectorOrder 
    def process(self, context):
        inst = context.create_instance(name="Test Instance", family='test', families=['test'])

        # if this is set to True, the families criteria in the instance plugin seems to be respected. 
        # If this is set to False, followed by the user manually enabling the instance in the UI, the families 
        # parameter on the instance plugin somehow isn't being evaluated correctly, and the instance plugin will
        # not run. If you change the families parameter to ['*'] in the instance plugin, the instance behaves
        # as if 'publish' was enabled to begin with after a manual toggle.
        inst.data['publish'] = False

        self.log.info('Test instance added.')

class TestValidationPlugin(pyblish.api.InstancePlugin):
    label = 'Validate Test Instance'
    order = pyblish.api.ValidatorOrder
    families = ['test']
    def process(self, instance):
        self.log.info("Instance has been processed")

If you toggle the instance to be enabled and click validate, nothing happens.

However, if you change families = ['*'] in the instance plugin, then the validation plugin will run when you enable the instance manually. Somehow when the 'publish' value on an instance starts as False, the families parameter isn't matching anymore or something.

mottosso commented 1 year ago

That does sound like a bug, thanks for the elaborate reproducible. Would you be able to see if you can spot a fix for this? A pull request would be most welcome.

tokejepsen commented 1 year ago

Think the data member active denotes the state of the instance in the UI, but publish should be considered as well.