Do Mapped Paths work on job environment variables? How do I make this work? I’m submitting Python jobs from a Linux workstation and it can be run on a Windows slave. I tried this and the environment variables are still Linux paths.
I’m using Deadline 8.
Environment variables in Deadline are not path mapped. I’m not sure if this is actually something which others would expect as a default behaviour as it is normal for env vars to be platform specific. However, if this is desired behaviour, you should be able to intercept the env var and path map using something like a JobPreLoad.py script which executes in front of the app plugin script. You could execute this for ALL jobs (any app plugins) if you use a GlobalJobPreLoad.py script. The reason you will probably need to do it ahead of the actual Python.py ap plugin script firing is becauese whatever you are executing within the Python.py plugin might need to ‘see’ these env vars earlier in the process.
Here’s an example:
docs.thinkboxsoftware.com/produc … preload-py
The all important Scripting API function is:
docs.thinkboxsoftware.com/produc … 24500131a4
[code]import os
from Deadline.Scripting import *
def main( deadlinePlugin ):
incomingEnvVar = os.environ[“MY_ENV_VAR”]
convertedEnvVar = RepositoryUtils.CheckPathMapping( incomingEnvVar )
deadlinePlugin.SetProcessEnvironmentVariable( “MY_ENV_VAR”, convertedEnvVar )[/code]
If you are already including the env var within the submitted job in Deadline (instead of it being on the system already), then retrieve this env var using the job properties:
def __main__( deadlinePlugin ):
job = deadlinePlugin.GetJob()
job.GetJobEnvironmentKeyValue( "MY_ENV_VAR" )
Note: I didn’t test this code, but it should get you close…
Thanks Mike,
That’s exactly what I needed.
Is it possible to remove specific job environment entries? In some scripts I use the env to store information, for example: I swap jobs between different modes/departments etc.
docs.thinkboxsoftware.com/produc … b6f91bc563
def __main__( deadlinePlugin ):
job = deadlinePlugin.GetJob()
job.SetJobEnvironmentKeyValue( "MY_ENV_VAR", "" ) # would set it to be empty
job.JobDepartment = "my department now!"
RepositoryUtils.SaveJob( job ) # don't forget to save it back to the DB
That’s close to what I’m doing at the moment, but I want to clean up some temp variables from the environment.
So there is no way in actual removing them from the environment?
Can I clarify…re: “environment” is that the environment of the currently running render process? or you must update the actual Deadline job object by removing 1 or more env vars completely from the job object? If it’s the former, then those env vars won’t exist after the render process has exited. If it’s the later, I don’t think anyone has ever asked for that before. Can I understand the use-case of why you need to actually “swap” a job? Deadline jobs tend to be submit, render, then throwaway. Can you instead submit a new job with the updated env vars as applicable and complete this one off instead?
An example:
One job script changes the job environment (stores the originals as new entries with prefix) with the necessary envVars to run in debug mode, so we can figure out with our local machine attached, what’s going wrong. Once the issue is fixed and production pipeline updated, for heavy jobs, we switch the env back to it’s original and restart the job process, so the better farm machines will take over again.
Some jobs now have problems, as some environment variables should be removed, instead they are blank.
How could I remove a variable from the jobs environment?
Ah, right, thanks very much for the explanation. So, I have already created a git issue back on 26th Jan to add an API function to “remove” an env var from a job. I’ll make sure to tag this thread, so I can update you when it has been implemented or once I have a better idea of timing.
Thanks!
Great!!
Thanks,
Michael
FYI. Feature now implemented as of 8.0.17.0, released today: Shrove Tuesday - 28th Feb:
docs.thinkboxsoftware.com/produc … provements
Happy Pancake Day!