Execute publish plugin without UI, headless with python

Hey everyone,

We currently have quite long publishing times for certain plugins.

I would like to execute the publish process on our farm by starting a software in headless mode, opening a scene, and executing a certain publish plugin.

I am wondering if I can reuse the existing publish plugings that alreaady work with the tk-multi-publish2 application, but directly in python.

So I am lookging for something like:

# Sudo code

# Import collector 
coll = sgtk.import_collector("MayaCollector")

# Import publisher hook 
hook = sgtk.import_hook("AnimationCachePublishHook")

# Publish each item
for item in coll.items(): 

    if not hook.accept(settings, item): 
        continue 

    if not hook.validate(settings, item): 
        continue 

    hook;publish(settings, item) 

Does this exist?

3 Likes

It does, you should just make sure that the farm machine you use has the toolkit instance. Then you should use it to open the scene in a certain engine and once the scene is opened you make sure the tookit knows the context “project, shot, task”. That way your publisher knows what hooks are available for this context. So this basically will be replication of the user interaction with publish app.
There is a small part of this process in this tutorial:

And one more video just about publishing:

1 Like

Hey @grover_gol,

thanks for all the material! The first Video seems to explain exactly what I want.

I will work through that and see if I can get it to work!

2 Likes