Mayabatch.exe engine

Is there an easy way to launch mayabatch.exe with a running maya shotgun engine.

When I change validation steps or add extra secondary exports I have to spend all day republishing thousands of assets.

I’d rather run this though something like manymaya or on our render farm.

1 Like

Hi Joe

So I think I understand, your making changes to the pipeline rules in for example the publish app, but of course, that will only affect publishes going forward rather than all Assets that have generated publishes in the past?
So you would like to create a script that looped over the Assets checked to see somehow if they had the required outputs conforming to the current validation standards and generated a farm job to create them if not?

I’m not sure if I can help you with all of that, and I’m not sure there is an “easy” way as such.

If it was me and I had a script that had identified an asset that needed its outputs regenerating, then I would probably handle the submission and bootstrapping my self. I’d create a job on the farm and provide it with a serialized context, and any other information required to bootstrap and set it to run a custom startup script in Maya.
That custom startup script would then bootstrap the engine and perhaps use the Publish API to run the publish process.

I just posted here and example of using the bootstrap API which might be of help?
We also have a webinar on the Publish API here.

1 Like

Mostly I need to know how to setup the environment so mayabatch.exe will start with an engine running. Preferably from a non shotgun python instance due to how we have our render farm setup.

If I’m in maya and set these environment variables when launching a mayabatch subprocess it works. Which is what I currently do when a model updates and I need to auto rig and then publish the rig with the api publisher.

    env = os.environ.copy()
    env['SGTK_ENGINE'] = 'tk-maya'
    env['SGTK_CONTEXT'] = sgtk.platform.current_engine().context.serialize()
    subprocess.Popen([mayabatch, '-command', 'python "execfile(pythonscript)"'], env=env)
2 Likes

Ah OK.

I assume this process is working because the userSetup.py script is already added to the PYTHONPATH by the tk-multi-launchapp when your current Maya session was launched.

If you would like to continue using the engine’s startup script rather than writing your own bootstrap code then you can do so. You will just need to ensure that the userSetup.py is added to the PYTHONPATH before Maya is launched and that you have set the SGTK_ENGINE and SGTK_CONTEXT.

1 Like