Had an idea I’d like to run by you guys.
Goal
To facilitate plug-ins that operate on Instance
's under certain circumstances, such as after a failure or custom event.
For example, if an instance of family “myFamily” fails validation, it’s family is dynamically, and temporarily changed to something like “myFamily.failed”.
Because it is now considered a different family, it will be compatible with other sets of plug-ins, plug-ins that support failed families.
Implementation
An example of how it could be used to repair broken Instance
's.
class SelectModel(pyblish.Selector):
def process(self, context):
instance = context.create_instance("MyModel")
instance.set_data("family", "model")
class ValidateModel(pyblish.Validator):
families = ["model"]
def process(self, instance):
if False:
current_family = instance.data("family")
instance.set_data("family", current_family + ".failed")
assert False, "Model is invalid"
class RepairModel(pyblish.Action):
families = ["model.failed"]
def process(self, instance):
# repair model here
In practice, instances would be re-evaluated once publishing has completed and if there are plug-ins that support the new family, they would appear in the GUI ready to be processed individually similar to how repair
works today.
Discussion
This would be an alternative to Actions, the benefit is alignment with processing in general, decoupling arbitrary actions from other plug-ins and the ability to develop Pyblish Action Packages.
On the other hand, the current coupling between a validator and it’s solution is very intuitive and it might be difficult - or at least of very little gain - to decouple them into separate plug-ins/files.
Thoughts?