submit vray scene export job to deadline

45 views
Skip to first unread message

Amit Yablonski

unread,
Apr 10, 2023, 7:34:46 AM4/10/23
to Python Programming for Autodesk Maya
Hey all.

I'm trying to submit (with python) a job to deadline that will export vray scene to a specified location.
the next step will be to send another job with dependency to the previous job that will render those vray scenes files with vray standalone nodes.

i managed to send a job with the right parameters that look similar to the job submitted from deadline submitter but it doesn't seems to to take the output path for the vray scene from the parameter, instead it take the path from the render settings field.
sometimes it renders instead of exporting vray scene files, not sure why.
in addition it doesn't export vray scene file foe each render layers if the maya scene contains it (i'm using render layer legacy)

i'm using and old script i have to send jobs to deadline.
in order to send vray scene export jon i cahnge the 'Renderer' to 'vrayExport' and specifiy the parameter 'VRayExportFile'
this is the job parameters:
Screenshot 2023-04-10 140341.png
maybe there is a better way to do it..


import subprocess
import pymel.core as pm
from maya import cmds
import sys
import os
import time


class DeadlineLayer:
    def __init__(self):
        self.version = cmds.about(version=True)
        self.scene_file = cmds.file(q=True, sn=True)
        self.project_path = 'example'
        self.camera = 'persp'
        self.priority = 50
        self.width = pm.getAttr("defaultResolution.width")
        self.height = pm.getAttr("defaultResolution.height")
        self.renderer_name = pm.getAttr("defaultRenderGlobals.currentRenderer")
        self.output_path = self.project_path + 'images/'
        self.vray_export_path = self.project_path + 'data/vray_scenes/'
        self.output_file_prefix = 'default_output_file_prefix'
        self.startFrame = str(int(pm.playbackOptions(q=True, min=True)))
        self.endFrame = str(int(pm.playbackOptions(q=True, max=True)))
        self.frame_range = self.startFrame + "-" + self.endFrame
        self.chunk_size = 1
        self.job_name = "default_job_name"
        self.output_directory = ''
        self.pool = 'none'
        self.group = ''
        self.batch_name = 'batch_name_default'
        self.plugin = 'MayaBatch'

    def maya_deadline_job(self, layer):
        """
        this function will collect scene file information and write a job file
        :return:
        """
        info_txt = 'Animation=1\n' \
                   'Renderer={}\n' \
                   'UsingRenderLayers=1\n' \
                   'RenderLayer={}\n' \
                   'RenderHalfFrames=0\n' \
                   'LocalRendering=0\n' \
                   'StrictErrorChecking=0\n' \
                   'MaxProcessors=0\n' \
                   'AntiAliasing=high\n' \
                   'Version={}\n' \
                   'Build=64bit\n' \
                   'ProjectPath={}\n' \
                   'ImageWidth={}\n' \
                   'ImageHeight={}\n' \
                   'OutputFilePath={}\n' \
                   'OutputFilePrefix={}\n' \
                   'VRayExportFile={}\n' \
                   'Camera={}\n' \
                   'Camera0={}\n' \
                   'Camera1=RENDERShape\n' \
                   'Camera2=frontShape\n' \
                   'Camera3=perspShape\n' \
                   'Camera4=sideShape\n' \
                   'Camera5=topShape\n' \
                   'UseLegacyRenderLayers=1\n' \
                   'IgnoreError211=0'.format(self.renderer_name,
                                             layer,
                                             self.version,
                                             self.project_path,
                                             self.width,
                                             self.height,
                                             self.output_path,
                                             self.output_file_prefix,
                                             self.vray_export_path,
                                             self.camera,
                                             self.camera,)
        maya_deadline_job_file = r'{}\maya_deadline_job.job'.format(os.getenv('TEMP'))
        with open(maya_deadline_job_file, 'w') as job_file:
            job_file.write(info_txt)
        return maya_deadline_job_file

    def maya_deadline_info(self, layer):
        """
        this function will collect maya deadline information and write a job file
        :return:
        """
        info_txt = 'Plugin={}\n' \
                   'BatchName={}\n' \
                   'Name={}\n' \
                   'Comment=Render Launch by Python\n' \
                   'Pool={}\n' \
                   'Group={}\n' \
                   'SecondaryPool=\n' \
                   'MachineLimit=0\n' \
                   'Priority={}\n' \
                   'OnJobComplete=Nothing\n' \
                   'TaskTimeoutMinutes=0\n' \
                   'MinRenderTimeMinutes=0\n' \
                   'ConcurrentTasks=1\n' \
                   'Department=\n' \
                   'Group=none\n' \
                   'LimitGroups=\n' \
                   'JobDependencies=\n' \
                   'InitialStatus=Active\n' \
                   'OutputFilename0={}\n' \
                   'Frames={}\n' \
                   'UserName={}\n' \
                   'ChunkSize={}'.format(self.plugin,
                                         self.batch_name,
                                         self.job_name,
                                         self.pool,
                                         self.group,
                                         self.priority,
                                         self.output_directory,
                                         self.frame_range,
                                         '',
                                         self.chunk_size
                                         )
        maya_deadline_info_file = r'{}\maya_deadline_info.job'.format(os.getenv('TEMP'))
        with open(maya_deadline_info_file, 'w') as job_file:
            job_file.write(info_txt)
        return maya_deadline_info_file

    def submit_to_deadline(self, layer):
        """
        this function will send current scene to deadline for rendering
        :return:
        """
        deadline_cmd = r"C:\Program Files\Thinkbox\Deadline10\bin\deadlinecommand.exe"
        job_file = self.maya_deadline_job(layer)
        info_file = self.maya_deadline_info(layer)
        command = '{deadline_cmd} "{info_file}" "{job_file}" "{self.scene_file}"'.format(**vars())
        process = subprocess.Popen(command, stdout=subprocess.PIPE)
        lines_iterator = iter(process.stdout.readline, b"")

submit_to_deadline('')



Justin Israel

unread,
Apr 10, 2023, 4:08:17 PM4/10/23
to python_in...@googlegroups.com
I haven't used Deadline before, so maybe someone with more experience will spot something. But just looking at your script, I was wondering if that was a copy-paste error in the way you build the project_path with the other parts of the path. 'example' + 'images/' ? I'm not sure what Deadline would do if it doesn't like the paths. Do they need to be absolute paths like your UI example? Do they need to exist?
Have you tried inspecting the maya_deadline_info.job file that you write to the tempdir and comparing it to the settings that you know to be working from the UI submission? Is the default renderer that you grab from the Maya api ending up being set to vrayExport?

On another note, I find that the way you are building your job file string is quite hard to read and very prone to mistakes if you don't make sure to line up the order of the format arguments. It would be much safer to use named template variables like "format {this} {that} {this} var}".format(that='123', this='abc'). Or to instead build it as a list and join it, so that you can read every value right where it needs to be and not have to deal with newlines:  

info_text = '\n'.join([
    'Foo=' + var1,
    'Bar=' + var2,
]) 

But aside from that, I don't have anything to add about how Deadline is behaving when it receives that job file.

Justin


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/88c5d12d-5bce-4eaa-bfe2-151761d9627cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages