Got a plugin that repairs some assets, but it seems to repair both valid and failed assets.
Is that expected behaviour?
Got a plugin that repairs some assets, but it seems to repair both valid and failed assets.
Is that expected behaviour?
Sounds like a bug.
If you can create something short to reproduce, I’ll have a look at this asap.
Edit: As a temporary workaround, in your repair method, you could look up the currently running instance from the results
dictionary of the Context, and see whether it has any failures. If it doesn’t, you could return early.
Scene creation:
import pymel
for count in range(0, 7):
pymel.core.spaceLocator()
Collector:
import pyblish.api
import pymel
class CollectLocators(pyblish.api.Collector):
"""
"""
def process(self, context):
for node in pymel.core.ls(type='locator'):
instance = context.create_instance(name=node.name())
instance.set_data('family', value='locators')
instance.add(node.getParent())
Validator:
import random
import pyblish.api
import pymel
class ValidateLocators(pyblish.api.Validator):
"""
"""
families = ['locators']
def process(self, instance):
assert bool(random.getrandbits(1)), 'Something is wrong with this.'
def repair(self, instance):
self.log.info('This asset failed validation: %s' % instance)
Thanks, I found the problem. It’ll be fixed in the next release for tomorrow.
Haven’t tried it out yet. On my list of things to do:)
Ok, no problem.
Its working:) Small note though, is that the failed assets don’t turn green when repairing. Pretty sure they used to do that, but no biggie if not.
Also for future reference, I always forget that you can register plugins, so the code example is better like this;
import random
import pyblish.api
import pymel
for count in range(0, 7):
pymel.core.spaceLocator()
class CollectLocators(pyblish.api.Collector):
"""
"""
def process(self, context):
for node in pymel.core.ls(type='locator'):
instance = context.create_instance(name=node.name())
instance.set_data('family', value='locators')
instance.add(node.getParent())
class ValidateLocators(pyblish.api.Validator):
"""
"""
families = ['locators']
def process(self, instance):
assert bool(random.getrandbits(1)), 'Something is wrong with this.'
def repair(self, instance):
self.log.info('This asset failed validation: %s' % instance)
pyblish.api.register_plugin(CollectLocators)
pyblish.api.register_plugin(ValidateLocators)