Run Standalone Script in Maya on deadline machine

Apologies if my question comes off as stupid. I am fairly new to deadline so I’m still learning the ropes.

I would like to create a deadline job/task from commandline that opens Maya, and then runs a standalone python script. The blade running the job will have access to both Maya and the python script. I don’t need it to render anything, which is what it seems most examples have, so I don’t know if those are the best resources to look at.

Would anyone have any ideas here, or a link to a resource to follow?

Thank you.

You could use the Command Line Plugin to simply call mayabatch.exe with whatever arguments you require.

That’s usually how I build Maya scenes and do other non-render Maya jobs.

Edit: Actually, I’m not sure if I understand what you mean by “standalone script” in this context, so perhaps this is missing the mark. Let me know.

Hi Daniel,

Thank you for getting back to, sorry for the delayed response. When I say standalone script, I mean I have a script that does some custom exporting on the maya scene. By standalone I meant it was independent of other deadline dependencies and the file itself.

Sorry for any confusion.

I think what’s inherently confusing me is the notion of frames/tasks per frame and other job/plugin parameters. In this case, we only need one task, and don’t need to specify any frames as I’m not rendering, and the export script is not dependent on any frame knowledge.

Do you have any advice on how to proceed here?

I agree, the whole frame thing is a bit confusing when you’re not dealing with frames. It helps to think of the frames as tasks instead of actual frames.

Then the question becomes how many tasks do you want to execute? The answer in your case is probably one, and in terms of what that task’s frame is labelled; it doesn’t matter.

For the actual plugin params you want to specify mayabatch.exe as your executable and tack on at least the -script <your-script-path> argument . Depending on your Maya version this script may be required to be a MEL script, in which case you can just make a MEL wrapper that loads your python script:

// Assuming you already have your module on path (usually via Maya.env)
print("Loading Python module");
python "from your_project.your_module import batchprocess";

Here’s an example of a dictionary I’ve used to write out a plugin-info file in the past:

cmd_plugin = {
    'SingleFramesOnly': 'False',
    'Executable': '{}'.format(MAYA_EXEPATH.replace('/', '\\')),
    'Arguments': '"{}" -script "{}" -command "$pipeline_args=\\"{}\\""'.format(sceneFile, scriptFile, pipelineArgs),
    'StartupDirectory': '',
    'ShellExecute': 'False',
    'Shell': 'default'
}

This particular command expects a scene file to load up, which is the first name-less argument. It’s worth noting that you can run mayabatch.exe without a scene file as well, only executing the supplied script. The -command <MEL COMMAND> flag was used to evaluate a global MEL string, which I fetched in the Python module later. JSON as base64 string I believe, just stuff that the Maya module needed to know regarding the job.

As for the job-info file, you have a massive amount of tweaking that can be done here, so I’ve only included the highlights that relate to your question:

cmd_job = {
    'Plugin': 'CommandLine',
    'Name': 'Job name goes here',
    'Frames': '1',
    'ChunkSize': '1',
    ...
}

So, a single frame and a single chunk does what you’d expect and creates a single task for this job. Presumably you’d get the same result with something like frames=1-10 and chunk=10. If you supplied frames=1-2 and chunk=1, your Maya script would run twice.

PS: The project I pulled this from was based around Maya 2018, so you might be best off confirming the command line arguments with whatever your target Maya version is.

1 Like

Thank you so much Daniel, this is likely what I need. I really appreciate your help here, wish I could return the favor somehow.

1 Like