Publish App hook to save file using tk-multi-publish2 templates?

Hey, gang,

Pre-COVID, our artists used the Photoshop and Maya Publishing Plugins to save their files on our shared storage and publish them to Shotgun. However, when we started working from home, many artists found the internet too slow for working on shared storage and have been saving their files locally and only connecting to shared storage when they want to publish the files to Shotgun.

It’s a little laborious to do this with the Photoshop and Maya Plugins, so I’ve been trying to build a hook for the Shotgun Desktop Publish app that would handle this renaming and relocating for them. It would do something like the following:

  1. Figure out what kind of file the user is publishing (e.g. psd, ma, mov)
  2. Use that and the selected Task to get a Path Template for the file
  3. Save the file to that path

Then the Publish App would use that new path for the latter steps of the process (i.e. “Publish to Shotgun”, “Upload for review”.)

Has anyone done that before? Any advice on clever ways to get those Path templates? And how do I ensure that latter publish plugins use my new path and not the original, incoming one?

Would love your advice!

Josh

4 Likes

Hey Josh,

I’ll ping the wider Toolkit team about this one, but there are a few ideas in this post that may help in the meantime.

1 Like

The publish plugin already contains a mapping for publish types - have a look at the built-in publish_file hook.
The templates are normally configured in the env config. You can add arbitrary template settings that could be your source/destination templates.

There is a conceptual question - when your users keep local files, are they in Shotgun-managed locations? By default the publisher extracts information from the original path, and uses it to form the publish path.

The “obvious” solution would be to do your things in the overridden publish method, and then call the superclass publish method for the rest. The items you pass to the original publish will have their paths set to the intermediate location.

4 Likes

Not sure, but this might also be of interest, though it’s not directly what you are asking.

5 Likes

Yeah, when working locally, the users don’t keep them in Shotgun managed locations, so the default publisher can’t make sense of the original path. I’m thinking of adding a Publish Hook that moves the file into a Shotgun managed location so the default publisher can pick it up from there, but I worry I’m still missing some subtlety in the process.

I’ll check out the publish_file hook and see if it’d be easier to override that. Thanks!

3 Likes

That looks great, Philip. I’ll give this a try.

Thanks!

3 Likes

woops I actually meant to post this link but the other one pointed there anyway.

3 Likes

Hi @JoshBurnell!

We pretty much done exactly that in our studio. We had to create a new publisher plugin and modify the existing plugins pretty heavily to achieve what we wanted. The basic run down is like this:

  1. The “Import Plugin”
    The purpose of the “Import Plug-in” is to copy the given files to a location that is known to the Pipeline. So only if you enter a file that cannot be resolved against a template, it will show up. It will give you a choice of possible templates to copy to. There templates will be filtered down with the information it has. So for instance it will only show templates that match the current context and the current file extension. Also it will let you enter all missing information, because there are some template keys that are impossible or very hard to determine (like “width”, “height”, “colorspace”, “scene name” to name a few).
  2. The “Publish Plugin”
    We modified the default Publish plugin so that it does NOT allow publishing of files that are not known to the pipeline. It’s purpose is to (if necessary) move the given files to the publish folder and register them to Shotgun. We had to add pretty big configuration file for that which contains all the information it needs for publishing. So this file contains the relationships between the work- and publish-templates as well as the publish types.
  3. The “Create Version” Plugin
    This plugin creates a Shotgun Version if possible. We also added some extra logic here to convert image sequences to movies that will be uploaded to shotgun. It is more or less the same as the provided “Upload for review” plugin.

So all in all we are able to publish almost any file from anywhere to the correct location in the pipeline. Which in off itself is a pretty cool thing! However there are some downsides to this. The first one would be that it can be very cumbersome to fill out all the additional information that is sometimes needed by the “Import Plugin”. Also not everyone knows where files should be going, so sometimes things end up in odd or wrong places.

Don’t know if all of that information is helping you, but maybe it sparks some ideas how to approach things.

Cheers,
Fabian

6 Likes

Dude, thanks! That’s super helpful.

A question about your “Import Plugin” step: How did you generate the UI for selecting templates and entering the missing information? Is there something in the Publish App API that facilitates that (like a hook or something), or did you have to alter the UI of the Publish App itself?

2 Likes

The “Import Plugin” is a PublishPlugin that we wrote. The plugin class provides 3 functions to hook into the Publisher GUI: create_settings_widget, get_ui_settings and set_ui_settings. These provide enough functionality for most use cases. So there is no need to alter the Publish App itself.

5 Likes

There’s also an example plugin I put together here that might help:

5 Likes