Custom publish plugin development question

Hi all,

I’ve been diving into the publishing process to make my own publishing plugin. I’ve read all the docs and read through Mustafa’s post about the topic. Just trying to wrap around my head around all the concepts. Most of it I get but especially how to control the flow and order of the publish plugins is still a bit vague to me. I’ve read about the order attribute but it still feels quick abstract.

I’d like to make a publish plugin for Maya that happens right after the extraction of a usd layer. Perhaps do some custom reordering or renaming of primvars. How do I make sure that plugin happens right after the extract_maya_usd.py. Also some plugins live in different addons but still get called by the publisher when publishing from for example maya.

Finally, my plugin is technically not extracting anything however it does happen during the extraction phase. Does that matter at all or is that merely symantics?

Thanks in advance. Still learning the concepts so bear with me

Ralph

In this case - since it’s tied to Maya USD Export you may be better of implementing a Maya USD Export chaser or alike and somehow feed that into the extraction process - unless you absolutely need to do it after the export has finished. Using an export chaser you can adjust the output still while it is in memory without needing to read the file again, etc.

The only downside is that you may be writing some logic that is maya-specific and not usd-generic.

Here is an example of a Maya USD export chaser inside AYON: Implement Maya USD Export Chaser to Filter Properties by BigRoy · Pull Request #193 · ynput/ayon-maya · GitHub

And there are some others on my github gists:

Thanks!

An export chaser in this case seems to be a good way to approach this so I will definitely look into those.

On a more general note, what would be the steps regarding order and calling plugins from other addons, like the case in the extract relative usd paths for example. That’s a concept I’m still struggling with a little bit. Let’s say I want to use a publishing plugin from somewhere else. How would you call that and define the order.

Thanks in advance!

The order is Pyblish’s weakness and its strength.

The nice things is, you can insert anything from anywhere. The bad thing is, it’s non-trivial to find the exact order that’d work for the use cases and there’s also nothing ensuring the order remains “safe” over time if someone ends up changing orders elsewhere. Nothing really defines dependencies, there’s just a float order and that’s how it’s processed.

There are some agreements from Pyblish itself, like CollectorOrder, ValidatorOrder, ExtractorOrder, etc. and there are some gentleman agreements (or maybe just my preference) like:

  • In collector order range: anything that doesn’t depend on anything else preferably do it as early as possible in CollectorOrder
  • in validator order I usually put validators first that happen to invalidate more often or are faster to run; that way an artist can be aware faster that something may be wrong in their publish instead of first waiting on a slow validation for a long time.
  • in extractor order, the exports usually happen around the ExtractorOrder - so if you want to do something just before, or just after, use the -0.5 and +0.5 ranges but there aren’t much other agreements I know of then.
  • in integrator order, run any cleanups last so push them a bit further so the integrator itself has triggered, etc.

Does that help?

Yeah that helps a lot, Thanks! Been looking into it a bit further and I think I start to wrap my head around it. So basically you can create any plugin anywhere as long as their class inherits the right plugin class? So in the case of a specific dcc it should inherit that one from that specific dcc e.g. Maya or Houdini. If I want a more generic plugin for multiple hosts it should inherit something like pyblish.api.InstancePlugin. Is that correct?

Yes correct - the only thing the host specific ones do, like the Houdini ones, is that it specifies:

  • The hosts attribute, which is used to filter Pyblish plug-ins to a currently registered host.
  • Often these also set settings_category attribute, which is an AYON-specific attribute that if set to the addon name that it’d be able to automatically apply those attribute overrides on the class from settings.
    • Instead of using that you can also implement a classmethod apply_settings(cls, project_settings) on Instance/Context Plugins, but that’s usually rarely done to keep things simple.
    • Both of the types of applying these settings occurs in the code here.
  • In some rare cases these also apply some additional host specific overrides or extra helper methods - just to ease development overall.

So technically there is no requirement to even use the host specific ones to target the host - your custom plug-in can do the exact same thing, without needing to import from the other addon.

Additionally, note that technically the plug-in can filter to multiple hosts, like hosts = ["maya", "houdini"] so that the plug-in is only relevant for those.

Thanks for the explanation. It’s all clear now.