###Goal###
Ability to disable plugins based on missing data in the context
####Usecase####
While working on the ftrack extension I ran into a situation which wasn’t apparent until now.
Normally plugins are dependent on an instance family. So if no instance with given family is found, the plugin doesn’t appear in the UI and doesn’t run.
pyblish-ftrack however is dependant on ftrack data being present in the environment variables and ability to import ftrack
.
Currently if the first selector runs into any issues, hence doesn’t manage to collect all the data needed for the rest of the plugins to run, they all still appear in the ui and try to run on each instance. To prevent them from failing we’re simply adding a condition to do nothing if they don’t find data they need, but that results in lots of ‘green’ plugins in the UI which effectively did nothing.
####Solution####
The solution might be allowing plugins to be run based on content of the context as well as instance family.
####Example####
- All pyblish-ftrack plugins need
ftrackData
data member in context to be able to do anything. - This data get’s created by select-ftrack-data plugin a passed into context.
- All plugins dependent on this data could not appear in the UI unless
ftrackData
is present.
Plugins could then look something like this:
# Pseudo Code
import pyblish.api
@pyblish.api.log
class ValidateFtrackVersion(pyblish.api.Validator):
""" Validates something really important"""
families = ['*']
hosts = ['*']
context = ['ftrackData']
version = (0, 1, 0)
def process_instance(self, instance):
ftrack_data = instance.context.data('ftrackData')
assert something_really_important