Handling custom actions and environmental variables
Muster custom actions can be spawned by the Dispatcher or the Render clients, depending if they are jobs based or chunk based.
In both scenarios, you can use inline Python execution to pass custom arguments to custom actions as well as to environmental variables values configured either on a template basis or as a job override.
Be aware also that the syntax of custom actions uses the backslash (\) as an escape character, so you may need to escape special characters used to build the command lines like:
- ; ⇒ \;
- = ⇒ \=
- % ⇒ \%
- > ⇒ \>
- < ⇒ \<
- : ⇒ \:
- / ⇒ \/
- \ ⇒ \\
A sample code that spawn the Windows shell and execute a command follows:
C:\\Windows\\system32\\cmd.exe /c echo Hello!
As introduced before, custom inline Python may be used. Muster automatically pass a job and a chunk object to the Python context. You can use them to build more complicated strings.
C:\\Windows\\system32\\cmd.exe /c echo job id: <%=job.getJobId()%>
You can use the special <%= to automatically print a value. If you need to construct more complex expression, you can pass back the output using muster.expressionPrint() function:
C:\\Windows\\system32\\cmd.exe /c echo job id: <%muster.expressionPrint(str(job.getJobId()))%>
Also pay particular attention when using inline Python either for actions or environmental variables. While the job object is always available, the chunk object is available only on chunks actions, but the environment may be shared for both scenarios.
So you can define a custom environmental variable using inline python in such way:
MYCHUNKID=<%if chunk not None: muster.expressionPrint(str(chunk.getChunkId()))%>
Also, if you activate on the Dispatcher and/or the Renderclient to export the Muster custom environment, you'll find the following environmental variables defined, either in a job execution context, or a custom action execution context:
MUSTER_JOB_NAME MUSTER_SUBMISSION_TIME MUSTER_PACKET_TYPE MUSTER_TASKS_MASK MUSTER_ENGINE MUSTER_PRIORITY MUSTER_INSTANCES_WORKING MUSTER_MAX_INSTANCES MUSTER_IS_PAUSED MUSTER_END_TIME MUSTER_START_TIME MUSTER_STATUS MUSTER_PROGRESS MUSTER_SUBMITTER MUSTER_NAME MUSTER_JOB_PORJECT MUSTER_JOB_DEPARTMENT MUSTER_JOB_CAMERA MUSTER_JOB_SHOT MUSTER_JOB_SEQUENCE MUSTER_JOB_ID MUSTER_PACKET_SIZE MUSTER_POOL MUSTER_EXCLUDED_POOL MUSTER_EXITCODES_ERROR_CHECK_TYPE MUSTER_LOGS_ERROR_CHECK_TYPE MUSTER_PARENT_ID MUSTER_JOB_TYPE MUSTER_DEPEND_ID MUSTER_DEPEND_MODE MUSTER_DEPEND_LINK_MODE MUSTER_REQUEUED MUSTER_IS_LOCKED MUSTER_IS_ARCHIVED also you get a MUSTER_PARAMETERS_* for each attribute inside the job
You can query those values, directly inside your action code, using getenv or whatever command your script/language supports.