Control the order of execution.
Plug-ins are sorted by this attribute. By altering the order of a subclass, you effectively have control over the order in which a particular plug-in is set to execute.
# Default order per plug-in superclassSelector: 0Validator: 1Extractor: 2Conform: 3
Sorting is performed via the sort function and works similar to this.
plugins.sort(key=lambda p: p.order)
By incrementing the order, you can offset how they are sorted and executed.
class ValidateAfter(pyblish.api.InstancePlugin):order = 1.5
As the default order for a Validator is
1, setting it to
1.5 means that this particular subclass will run once all validators still at the default order have finished.
To protect yourself against changes to the inherited order, it is recommended that you offset the order as opposed to setting it to an absolute value.
class ValidateFirst(pyblish.api.InstancePlugin):order = pyblish.api.ValidatorOrder + 0.5
Here's an example of three plug-ins of the same superclass, set to run one after the other.
class ValidateFirst(pyblish.api.InstancePlugin):order = pyblish.api.ValidatorOrder + 0class ValidateSecond(pyblish.api.InstancePlugin):order = pyblish.api.ValidatorOrder + 0.1class ValidateThird(pyblish.api.InstancePlugin):order = pyblish.api.ValidatorOrder + 0.2
Each order have a special meaning to Pyblish.
Implies Collector. It is run first, sometimes automatically, such as when launching the Pyblish QML graphical user interface.
Implies Extraction. It does not run if any plug-in within range
1-2 has produced an error.
Keep in mind that if you offset an order too far, you effectively alter it's role in the Pyblish ecosystem which may cause undefined behaviour.
class ValidateSecond(pyblish.api.InstancePlugin):# When does this plug-in run?order = 6
If you find yourself working with a large number of interdependent plug-ins, it is recommended that you subclass the super-classes and make ordering explicit.
import pyblish.api as pyblishclass DefaultValidator(pyblish.InstancePlugin):order = pyblish.ValidatorOrderclass PreValidator(pyblish.InstancePlugin):order = pyblish.ValidatorOrder - 0.1class PostValidator(pyblish.InstancePlugin):order = pyblish.ValidatorOrder + 0.1
You can then replace the provided classes with your with your own.
import pipeline.pyblishclass ValidateSomething(pipeline.pyblish.PostValidator):...