Use FamilyPlugin to load InstancePlugin?

Hi, I am researching a production tracking solution for my studio, and try to implement Pyblish.
This is awesome, btw.
After reading about Pyblish docs and Wiki, I have a question about assigning families in InstancePlugin.

If I am not misunderstand, family is like a tag, we need to assign(code-in) families into InstancePlugin. In this case, say we defined a new family, we than have to update the families in the InstancePlugin which can be support for the new family. Right ?

What if we use FamilyPlugin Class to assign all InstancePlugin we need for this family in there ?

Would that be more easy in management ? Or this concern will disappear in practical use ?

Thanks.

Hi @davidpower, welcome to the forums. Let me get back to you on this tomorrow.

A family is a type or class of data. You assign a family to a set of data in order to indicate compatibility between it and one or more plug-ins, which is then used to determine which instances to process with which plug-in.

For example, ValidateMeshHoles and ExtractObj are each compatible with data of family geometry whereas ValidateRange and ExtractCurves are compatible with data of family animation. With these two instances present, each of these four plug-ins will run, but each will only run on instances it is compatible with. That is, instances of geometry will be processed by ValidateMeshHoles and ExtractObj, but not the other two.

Yes, I think you’ve got the idea.

I’m not entirely sure I understand, perhaps you could post an example?

Is this what you are thinking?

from pyblish import api
import my_pipeline

class MyPlugin(api.InstancePlugin):
  families = my_pipeline.dynamic_families("some_criteria")

Where dynamic_families returns a list based on "some_criteria".

Thanks for reply ! @marcus

The example you gave was nice, I think this will solve some special situation.

But I found that I kind of misunderstood the knowledge about family register and asset creator. I might need to rephrase my question.

Sorry about that. :sweat:

I was thinking if we could use .json file to store the info about the family, and a list of instancePlugin we need for that family.

from pyblish_starter import api
import json

api.register_family(
    json.load(my_family_file_path)
)

The reason I ask this was worrying about updating family support list for each instancePlugin might easily messed up, if there are lots of instancePlugin and the management we did wasn’t good enough.

Am I worry too much ? Or defining instancePlugin list in family creation will cause more trouble ?

Thank you for your patient and your time !

:beers:

Ok, I must admit I’m not entirely seeing the difficulty.

What typically ends up happening is that one has a directory of 10-100 plug-ins - one per file - where each plug-in is made compatible to a given family and is only ever relevant or visible when data of this family is present. It’s built around the idea that you could have hundreds of plug-ins operating on various kinds of data, such as model.low, rig.proxy, rig.cloth or specialcase.rig.explode.

The workflow is typically (1) identify the kinds of data you have in your asset pipeline - e.g. model, rig and animation - and then (2) build plug-ins to accommodate each kind. In the case of discovering new data, you could either write new plug-ins to accommodate those, or update your existing ones to include support for the new data.

I think at this point an example scenario would really help. How about you mock up a few plug-ins to illustrate the challenge you envision, and then we’ll take it from there?

Got it, and thanks for the explain about the workflow !

I must say, the current workflow is quite good, I wasn’t mean that it’s easy cause trouble, sorry if words I choose made it looks that way (my English needs more practice).

Yes, I will try more to test it out.

Thanks again !

You are most welcome, thanks for clarifying and happy you like it. :slight_smile:

If you do think of workflow improvements, please do continue to share. There are likely many new and potentially better ways ahead that no one has simply thought of yet.

Here is some more food for thought, on complex workflows.

Hi, been a while on this topic.
I tested and found a lot, was like a spider dancing on a big web.

Currently I am working on our own plugins (config), and reminds me my post here.
I found that what I do now is just what @marcus wrote, amazing,

so maybe add some follow up about it.


I put a family.py at some where near by.

# family.py

class Pipeline(object):
    mesh = 'pipeline.mesh'
    transform = 'pipeline.transform'
    rig = 'pipeline.rig'

and one families.py

# families.py

import family

modelDraft = [
    family.Pipeline.mesh,
    family.Pipeline.transform
]

rig = [
    family.Pipeline.rig
]

finally in the plugin I can set the family / families with text editor’s auto complete ( I use sublime text + anaconda )

import pyblish.api
import family # or `import families`

class MyPlugin(pyblish.api.InstancePlugin):
    """doc"""
    hosts = ['maya']
    families = [family.Pipeline.mesh, family.Pipeline.transform]
    # or 
    # families = families.modelDraft

    def process(self, instance):
        pass

That’s it.

Thanks @marcus, this is really great.

That’s a good idea @davidpower, thanks for sharing!