Auto-Correct during Validation

Hey all,

Has anyone approached auto-correction during validation? Take a very simple scenario where an unset attribute on a node would cause a plugin to fail.

Given that each plugin typically has a specific goal, I was considering adding a function to the plugin that attempts correction (add the attribute). Does this idea go “against the grain” of the API? More importantly, has anyone done this or added this type of functionality?


Hi @Claudio, welcome to the forums! :slight_smile:

To you question, there’s nothing preventing this from happening within the API. There are “guidelines” for how to use it - i.e. CVEI see here and here - one of which being that Validation is a read-only operation, in which case this might be considered “against the grain”.

But even “Validation” is a guideline and nothing you need to explicitly follow. Each stage is a number indicating the order in which to run your plug-ins, and you could add your own “Pre-validation” stage which involved scene mutations.

class MyPreValidation(api.InstancePlugin):
  order = api.ValidatorOrder - 0.1

If you’re asking for opinion, then I believe you’ll quickly discover why you’d want to keep validation immutable and that your artists trust in the tool might waver if it’s making automatic and invisible changes to their work. Pyblish as a whole is generally read-only, with the one exception being Actions, primarily to keep its use trustworthy and failsafe.

Pre-validation sounds like a better approach if we decide to follow through. Thanks!

Additional question: is it good practice to fail on collection? For instance, when a plugin collects specific nodes in a scene, I’d be inclined to raise if they can’t be found (early exit). However is it better to perform this test in a separate validation test?

Personally, that sounds like a validation failure to me. You can fail on collection, but default behavior is to not stop until after validation has run. If you wish to override this, you can have a look at writing a custom “test”.