Discovering representation destination beforehand

Is there a handy way to discover where ‘this publish will put files’ ? I mean if I am publishing an instance with several representations and one of those representations needs to point to the the published path of another representation being published in the same run.

(a somewhat forced) example:

  1. model publish, will output an .abc
  2. same model publish would output a thin usd file referencing that same .abc file

Is this something acheivable or is this just publish twice to the same version kind of thing requiring two runs of pyblish?

I might not be the most knowledgeable on this topic so I’m very curious too! :slight_smile:

All I know is that at the time of collecting a publishDir is collected which I believe should point to the expected published folder path. Using that you can at least identify where files will roughly show up.

Then if you need to know exactly where a file will show up - I’m not sure there’s such a thing. The integrator “builds that destination name” after the Extractors so before Integrating that knowledge might not be available.

Unfortunately no easy way method for predicting the published path of a representation. I think there should be so PRs are welcomed :slight_smile:

As @BigRoy mentioned, the resources plugin would be a good place to start as it’ll get you the directory path.
For the file names you’ll need to dig into the anatomy templates and retrieve the template for the representation, then fill the template in with data.

You might be lucky and get some advice from @iLLiCiT

This is one of reasons why we’re working on custom USD resolver. This approach has many limitations that are usable only for strict and very specific workflows.

You would have to copy the logic from integrate to your plugin, get_template_name and the way how data for template formatting are collected → here may be an issue as some data may not be available yet, also it would work only for single file representations.

data = {...}
template_name = get_template_name(...)
anatomy = context.data["anatomy"]
template = anatomy.templates[template_name]
path = template.format(data)

Yeah I imagined that the USD resolver would solve this, but in the meantime I’m looking into using the integrate logic.