Does anyone have a working Python template?

Viewing 4 posts - 1 through 4 (of 4 total)
  • 21st August 2013 at 1:18 pm #14511

    ..that I could have a look at?

    I want to submit a pythonfile to the farm. No need to check stdout.
    Basically just sending a line like X:test.py and it should be sent to the first computer available for execution.

    commandline would look something like this: C:\Python26\python.exe X:\test.py

    28th August 2013 at 2:54 pm #15230

    Seriously? noone has one?
    Not even a commandline one? say if I want to just do an ECHO “whatever”

    6th September 2013 at 3:00 pm #15232

    Hello,

    I’m not sure exactly what you’re trying to do by submitting a python file, but I’ll give you an example of how I’m using Python with Muster.

    I use Python as a wrapper to pre-process information before submitting a render. I have my python scripts in a drive all the render blades can see. In my case it’s something like:

    /p/scripts/muster

    If I open the Muster console I can configure the way any of the blades handle each job submission template. For example I created a Job Submission Template called Vray_Caching. In that template I created some submission parameters to pass to the Python script:

    DECLARE SUBMISSION
    {
    SET ENABLE_ADDITIONAL_FLAGS 1

    ADD VRAYFILENAME FILE_SELECTOR “” “Maya File” “Specify the Maya file to export from” NOTACTIVABLE MANDATORY SUBST *.*
    ADD PRERENDERSCRIPT FILE_SELECTOR “” “Pre-Render Script File” “Specify the pre-render script mel file” NOTACTIVABLE MANDATORY SUBST *.*
    ADD VRAYOUTDIR FOLDER_SELECTOR “” “Vrscene directory” “Specify the output path for the vrscene files” NOTACTIVABLE MANDATORY SUBST
    ADD VRAYSTARTFRAME INTEGER_INPUT “1” “Start frame” “Specify the starting frame for the rendering job” NOTACTIVABLE MANDATORY NOSUBST
    ADD VRAYENDFRAME INTEGER_INPUT “1” “End frame” “Specify the ending frame for the rendering job” NOTACTIVABLE MANDATORY NOSUBST
    ADD VRAYBYFRAME INTEGER_INPUT “1” “By frame” “Specify the frame step for the rendering job” NOTACTIVABLE MANDATORY NOSUBST

    # Map fields to Muster internal start/end/by frame values
    MAP job_file VRAYFILENAME
    MAP pre_render PRERENDERSCRIPT
    MAP out_dir VRAYOUTDIR
    MAP start_frame VRAYSTARTFRAME
    MAP end_frame VRAYENDFRAME
    MAP by_frame VRAYBYFRAME
    }

    Then I send these to my python script:

    DECLARE ENGINE_LINUX
    {

    SET PLATFORM_ENABLED 1
    SET ENABLE_ERROR_CHECK 1
    SET ENABLED_BY_DEFAULT 1
    SET FRAMESFLOATS 0
    #need to send in the following order
    # file name
    # pre render script file
    # output directory. This is sent so the render blade can create the directory and set the permissions if needed
    # start frame
    # end frame
    # by frame

    SET COMMAND_LINE “%ATTR(job_file) %ATTR(pre_render) %ATTR(out_dir) %ATTR(start_frame) %ATTR(end_frame) %ATTR(by_frame)”

    This command line is sent as arguments to the script. Before submitting this job, I configure the render blade by opening the Muster Console and right-clicking on any computer node. This will give you a list of options. Choose Configuration->Configure. This will pop up another window. Select Templates, then select the Job Submission Template. In my case it’s Vray_Caching. You can then direct that submission to a python script. From the command line above each argument is sent to python. In my Python script I will have something to parse the arguments then run my Maya Render command with those arguments.

    There is nothing stopping you from using the print statements instead for testing. Going back to the Muster Console you can see the output of those print statements by opening the workstation log for that render blade.

    I hope this ramble has helped.
    Andrew

    9th September 2013 at 3:30 pm #15233

    Here is how I use Python in combination with Muster. Basically I use it as a wrapper to pre-process information before sending it off to render. There are a few things you need to do first to set it up.

    1. set up Job Submission Templates
    2. Set up render blades to receive muster commands
    3. Set up Python file to receive muster command

    1. Set up the Job Submission Templates.

    I’ll use one example I have here where I send a file plus the output directory to my Python script. The Job Submission Template will have the custom GUI input boxes.

    ECLARE TEMPLATE
    {

    SET TEMPLATE_NAME “Houdini”
    SET TEMPLATE_DESC “Houdini rendering”
    SET TEMPLATE_UID 51
    SET TEMPLATE_LOGIC MULTIFRAME
    SET DEFAULT_PRIORITY 1
    SET DEFAULT_POOL “Houdini”
    SET MAXIMUM_LICENSES 15
    SET DELAY_GROUP “Global”
    SET DELAY_TIME 0
    }

    DECLARE MULTIFRAME
    {
    SET ENABLE_FRAME_CHECK 1
    }

    DECLARE SUBMISSION
    {
    SET ENABLE_ADDITIONAL_FLAGS 1

    ADD HOUFILENAME FILE_SELECTOR “” “Houdini scene file” “Specify a houdini file.” NOTACTIVABLE MANDATORY SUBST *.*
    ADD HOUPROJECTPATH FOLDER_SELECTOR “” “Department Directory” “Specify the department path” NOTACTIVABLE MANDATORY SUBST
    ADD HOURENDERPATH FOLDER_SELECTOR “” “Image destination” “Specify image output folder” ACTIVABLE MANDATORY NOSUBST
    ADD HOUSTARTFRAME INTEGER_INPUT “1” “Start frame” “Specify the starting frame for the rendering job” NOTACTIVABLE MANDATORY NOSUBST
    ADD HOUENDFRAME INTEGER_INPUT “1” “End frame” “Specify the ending frame for the rendering job” NOTACTIVABLE MANDATORY NOSUBST
    ADD HOUBYFRAME INTEGER_INPUT “1” “By frame” “Specify the frame step for the rendering job” NOTACTIVABLE MANDATORY NOSUBST

    SET BUILDHOUFILE FILE_BUILDER HOUFILENAME HOUFILENAME 1 “#”
    SET GUESSPROJECTPATH PATH_BUILDER HOUPROJECTPATH HOUFILENAME “\scenes” “”
    SET GUESSPROJECTPATH2 PATH_BUILDER HOURENDERPATH HOUFILENAME “\scenes” “\renders”

    # Map fields to Muster internal start/end/by frame values
    MAP start_frame HOUSTARTFRAME
    MAP end_frame HOUENDFRAME
    MAP by_frame HOUBYFRAME
    MAP job_file HOUFILENAME
    MAP job_project HOUPROJECTPATH
    MAP output_folder HOURENDERPATH

    }

    With the mapping set you can then use it with the command line output in Muster. Here is a partial code:

    DECLARE ENGINE_LINUX
    {

    SET PLATFORM_ENABLED 1
    SET ENABLE_ERROR_CHECK 1
    SET ENABLED_BY_DEFAULT 1
    SET FRAMESFLOATS 0
    SET COMMAND_LINE “%ATTR(output_folder) %ATTR(job_file)”

    This part will send the output path and file name gathered from the user input in the Muster Console and send it to the python file. In my case I have all the rendr blades on a Linux environment.

    2. Set up render blades to receive muster commands

    In the Muster Console, looking at the Instances view, pick a machine to test on. Right-click on this machine and select Configuration->Configure. This will pop up another window showing some option configurations. Select Templates. You will see all the Job Submission Templates. Select the one you were just editing. When you click on the arrow button beside the Template name you will see three options, Executable,Executable Home, and Executable starting folder. For the executable put a directory all the render blades can access. In my case I have a /p/script/muster directory with all my scripts. In there I have created a Python script, so the three lines will look like:

    executable: /p/scripts/muster/python_script_name.py
    executable home: /p/scripts/muster
    executable starting folder: /p/scripts/muster

    3. Set up Python file to receive muster command

    Now I have a Python file that will receive the command from Muster with all the options as arguments. It will look like this:


    start


    #!/usr/bin/python

    from optparse import OptionParser
    import os

    parser = OptionParser()
    (options, args) = parser.parse_args()

    print ‘Receiving commands from muster. Submitting now…’
    output_dir = args[0]
    sceneFile = args[1]
    print ‘Received all the arguements as:nScene File:%snOutput Folder: %s’ % (sceneFile,output_dir)


    end



    This is a bare bones script for testing. When you submit a render from within the Muster console, it will be re-directed to your python script. You can see the output of this transaction by going to the Muster Console and right-clicking on the render blade you submitted to ( just specify the Include Pool option to the specific instance machine ) and select the Workstation Logs option (CTRL-J). This will pop up all the transactions with Muster and that machine. You can then read all the outputs from your Python file. Double click on the log with the latest time stamp.

    Hope this helps,
    Andrew

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.