While creating various plugins, doing the following feels limited:
- access the failed instances from a validator that finished
example: i want to access the failed instances of a validation-plugin, in the select_failed_mesh action.
My expectation in OOP would be that the validator-instance can track which (pyblish)instances it ran on.
The action has access to the validator-plugin, therefor it has access to the (pyblish)instances.
class ActionSelect(pyblish.api.Action): def process(self, context, plugin): print plugin.instances
But this is not currently the case. So I find myself doing it in this non-intuitive way for now.
class ActionSelect(pyblish.api.Action): def process(self, context, plugin): # because pyblish doesnt support getting instances from a plugin yet # we have to do this manually :( # if only we would get the plugin instances when using an action instances =  for result in context.data["results"]: if result["error"] and result["plugin"] == plugin: instance = result["instance"] instances.extend(instance)
discovered following helper function while going through sourcecode , don’t think there is any docs online.
class ActionSelect(pyblish.api.Action): def process(self, context, plugin): instances = pyblish.api.instances_by_plugin(context, plugin)
but instances are not filtered. so it selects both failed and successfull meshes.
dependency injection UX
Also worth noting:
dependency injection allows following code to run, but since instance is always None it’d be better to not allow this.
not sure what i’d expect to happen here since an action runs on a plugin, and a plugin can run on multiple instances, not just 1 instance. But easy to get confused here.
class ActionSelect(pyblish.api.Action): def process(self, context, plugin, instance): print instance # prints None