-
Notifications
You must be signed in to change notification settings - Fork 47
Ordering
Control the order of execution for your plug-ins.
Plug-ins are ordered via an inherited order attribute. Each type of plug-in default to a particular order which looks like this.
Selector: 0
Validator: 1
Extractor: 2
Conform: 3You can find their attribute in the API documentation too.
By incrementing the order, you can offset how they are sorted and executed.
class ValidateAfter(pyblish.api.Validator):
...
order = pyblish.api.Validator.order + 0.5Which would cause the validator to process after all other validators.
You could then extend upon this with something like.
class ValidateFirst(pyblish.api.Validator):
...
order = pyblish.api.Validator.order + 0
class ValidateSecond(pyblish.api.Validator):
...
order = pyblish.api.Validator.order + 0.1
class ValidateThird(pyblish.api.Validator):
...
order = pyblish.api.Validator.order + 0.2However, keep in mind that the order attribute is global and includes all plug-ins; including selectors and extractors. So if you were to do:
class ValidateSecond(pyblish.api.Validator):
...
order = 6You'll be certain to cause problems. (When is this one run?)
To have a look at the default orders, you can print them, or look to the http://docs.pyblish.com.
>>> import pyblish.api
>>> pyblish.api.Selector.order
0
>>> pyblish.api.Validator.order
1
>>> pyblish.api.Extractor.order
2In production, I would suggest you subclass the plug-in classes to make things explicit.
pipeline.py
import pyblish.api
class DefaultValidator(pyblish.api.Validator):
order = pyblish.api.Validator.order + 0.5
class PreValidator(pyblish.api.Validator):
order = pyblish.api.Validator.order + 0.0
class PostValidator(pyblish.api.Validator):
order = pyblish.api.Validator.order + 0.9And then use these for your plug-ins instead.
/my_plugins/validate_something.py
import pipeline
class ValidateSomething(pipeline.PostValidator):
...As you modify order, Pyblish QML will display the resulting order of each plug-in in the list of plug-ins.