Skip to content
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

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

Open
guruBry opened this issue Feb 11, 2023 · 2 comments
Open

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

guruBry opened this issue Feb 11, 2023 · 2 comments

Comments

@guruBry
Copy link

guruBry commented Feb 11, 2023

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
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants