I am attempting to use Pyblish as a framework for validating rigs. One use case is to validate a rig by comparing it to historical versions of the same rig – ensuring not unexpected changes have occurred.
To do this I created the following five plugins:
collectRigVersions : ContextPlugin : api.CollectionOrder – 0.1
Looks in the context for a rig path and a list of source control version numbers to compare against – then extracts each version to a separate file. Calls context.create_instance for each rig file we write out and stores the rig path in the instance.
openScene : InstancePlugin : api.CollectionOrder
Opens the scene in Maya
switchReference : InstancePlugin : api.CollectionOrder + 0.1
Updates the reference path of the rig within the maya scene to the rig path stored in the instance data
validateBoneCount : InstancePlugin : api.ValidateOrder
Counts how many bones are in the rig and checks they do not exceed bone count limits. Stores this value in the instance data so it can be utilised later down the chain
compareBoneCount : ContextPlugin: api.ValidateOrder + 0.1
Cycles over all the instances in the context and compares the value of all the bone count data if there is any
I then create a blank context and populate it with data that I know my collectRigVersions context plugin will be looking for.
cntx = pyblish.api.Context() cntx.data['rigPath'] = r"//path/to/a/rig.ma" cntx.data['rigVersions'] = ['local', 3, 6, 14] cntx.data['romPath'] = r'//path/to/an/animation.ma' # -- Execute the publishing result_cntx = pyblish.util.publish(context=cntx)
The resulting output of this is:
Collecting and Extracting Rig Files Opening Scene Opening Scene Opening Scene Opening Scene Re-Referencing Rig Re-Referencing Rig Re-Referencing Rig Re-Referencing Rig Validating Bone Count Validating Bone Count Validating Bone Count Validating Bone Count Comparing Results between all tests
This output makes sense, especially after having a look at the publish function, as it grabs all the plugins (sorted by collectionOrder) and cycles over each plugin and then cycles over each instance – meaning each instance moves forward through the collection order together. That certainly makes a lot of sense for a lot of scenarios!
The downside this gives is that it’s opening a scene four times, then updating the reference four times within the same scene (the last scene to be opened), then validating bone counts four times to the last opened scene. This ultimately results in all of our tests being run multiple times over the same scene file. The desired ordering (in this scenario) would be something like this:
Collecting and Extracting Rig Files
Opening Scene Re-Referencing Rig Validating Bone Count Opening Scene Re-Referencing Rig Validating Bone Count Opening Scene Re-Referencing Rig Validating Bone Count Validating Bone Count Opening Scene Re-Referencing Rig Validating Bone Count Validating Bone Count Comparing Results between all tests
However, I am unsure how to achieve this with the ordering mechanism and the way the publishing loop works – do you have any ideas how you might approach this? I noticed the thread relating to graph based pipelines, is that in development at all? (https://github.com/pyblish/pyblish-base/issues/143)