i noticed some un intuive behaviour when using a validator after registering 2 plugins.
i have
1 plugin with families set to [‘character’, ‘mesh’]
1 plugin with family set to “joints”
I assume when I set family property, then the families property automatically becomes [family]
but this is not the case currently
import pyblish.api
class ValidateScene(pyblish.api.ContextPlugin):
"""character and environment should not be in the same scene"""
label = "no scene clash"
order = pyblish.api.ValidatorOrder
hosts = ["maya"]
# families = []
def process(self, context):
chr_found = False
env_found = False
for instance in context:
print '---'
families = instance.data.get('families', [])
family = instance.data.get('family')
print families
print family
if family and family not in families:
families.append(family)
if 'character' in families:
chr_found = True
elif 'environment' in families:
env_found = True
assert not (chr_found and env_found), "scene shouldn't contain a character and an environment"
prints out
---
['character', 'mesh']
character
---
[]
joints
as you can see in the second plugin where we only set family and not families we have an empty array.
this makes sense since we didn’t save the metadata in the _data dict of our instance.
but from a user experience POV this feels odd.
Would it not be nicer if we instead could do the following:
instead of
families = instance.data.get('families', [])
family = instance.data.get('family')
if family and family not in families:
families.append(family)
if 'character' in families:
chr_found = True
we can do
for instance in context:
if 'character' in instance.families:
chr_found = True
this seems like a more pythonic setup to me. would you agree?
currently metadata is stored in the data dict.
but properties that are vital to an instance would make sens to store as properties of the class
since pyblish is build around instances and plugins, it would be great if all instances had a default value of self.families = []
and when you set family, self.families would be autofilled with the family
i’m interested to hear what you think and what kind of work would be involved. I’d be happy to get involved.
Thanks for flagging this, family is the predecessor of families, back in the days when there could be only one. I’m off on holiday until end of next week, but will engage in this topic more once I’m back.
no worries, enjoy your holiday first of all !
I’ll still be here when you get back.
The main reason family is still used is because the qt GUI only supports family, and not families.
it uses family to decide which “category” to show an instance under.
It might be worth updating the GUI instead to support a custom category property instead of using family. so plugins can completely get rid of family and replace it with families.
The main reason family is still used is because the qt GUI only supports family, and not families.
it uses family to decide which “category” to show an instance under.
i believe QML handles this correctly actually and uses the first element from families
it appears every plugin has a family by default named “default”
i’d expected families would return an empty list by default
As far as I’m concerned, I’m happy to forget all about family by now and make any changes necessary to make families work across the board. If you find anywhere where families does not work, then that’s a bug and something to be fixed.