Environment vars not reaching event plugin?

Discussion and Support of Deadline, the Render Management System
mmmancact
Posts: 7
Joined: Fri Sep 15, 2017 11:08 am

Environment vars not reaching event plugin?

Postby mmmancact » Wed Oct 04, 2017 5:51 pm

I'm testing event plugins in Deadline 10 (10.0.0.42), and when the OnJobFinishedCallback is triggered, I'm not seeing the environment variables I've set on the job. For example, I've set a var for "REZ_CONFIG_FILE" on the job to a custom path; the direct python os.environ shows the regular system setting for the var, and the result from the plugin object's GetProcessEnvironmentVariable is empty. I don't believe there should be anything else monkeying with the env vars.

Have I missed something? Is this not supported? Is this a bug?
Thanks!

eamsler
Posts: 1757
Joined: Thu Dec 16, 2010 1:02 pm
Location: Winnipeg, MB, Canada

Re: Environment vars not reaching event plugin?

Postby eamsler » Mon Oct 09, 2017 11:09 am

mmmancact wrote:I've set a var for "REZ_CONFIG_FILE" on the job to a custom path


I guess a good starting put is where/how have you set that variable?

Deadline does environments in kind of a peculiar way. We build up a dictionary using SetProcessEnvironmentVariable() and then pass that dictionary *only* to the process we ran. If you're using os.envrion[] to set things, that might work, but it won't touch the underlying dict that GetProcessEnvironmentVariable() is using, and it will only set on the current Python Sandbox. Meaning if an event runs inside another sandbox, it won't see what you set before.

This is a pretty common issue... I bet we could use a Blog post about it.
Edwin Amsler
Head of Support
Thinkbox Software Inc
+1-866-419-0283 ext 804

Winnipeg

mmmancact
Posts: 7
Joined: Fri Sep 15, 2017 11:08 am

Re: Environment vars not reaching event plugin?

Postby mmmancact » Mon Oct 09, 2017 1:27 pm

For this particular test I tried setting it from the Monitor on the Job Properties -> Environment in super user mode, and resubmitted it. It shows up in the main job, but not the events.

User avatar
MikeOwen
Posts: 3505
Joined: Thu Jul 19, 2007 5:00 am
Location: London, UK
Contact:

Re: Environment vars not reaching event plugin?

Postby MikeOwen » Mon Oct 09, 2017 2:29 pm

"Disable Event Sandboxing" is disabled by default in the repo config options, and rightly so, as you ideally want each event execution to execute in a clean environment:
https://docs.thinkboxsoftware.com/produ ... ient-setup
As a result, none of the job's env vars will make it through to this new clean environment. So, in the case of a "OnJobFinishedCallback", I would query the Deadline job object and re-apply the env vars at entry.
Alternatively, enable the above checkbox setting in your repo, restart Deadline Slave and possibly have a dirty environment. ;)
Mike Owen
Solutions Architect
Thinkbox / AWS

mmmancact
Posts: 7
Joined: Fri Sep 15, 2017 11:08 am

Re: Environment vars not reaching event plugin?

Postby mmmancact » Mon Oct 09, 2017 3:58 pm

Ah, okay. I was trying to get vars out of the object to, but maybe I was digging in the wrong place. I'll come back here if I can't find it.

Thanks!

User avatar
MikeOwen
Posts: 3505
Joined: Thu Jul 19, 2007 5:00 am
Location: London, UK
Contact:

Re: Environment vars not reaching event plugin?

Postby MikeOwen » Mon Oct 09, 2017 4:12 pm

https://docs.thinkboxsoftware.com/produ ... 6def9b9467

Code: Select all

print job.GetJobEnvironmentKeyValue( "REZ_CONFIG_FILE" )
envVarList = job.GetJobEnvironmentKeys()
for key in envVarList:
    print( "%s=%s" % ( key, job.GetJobEnvironmentKeyValue( key ) ) )


(disclaimer: code not tested/from memory)

In other semi-related news, I actually had an interesting chat with another customer the other day about how we should probably do more to support REZ straight 'out-of-the-Deadline-box'. Need to think some more about this...
Mike Owen
Solutions Architect
Thinkbox / AWS

mmmancact
Posts: 7
Joined: Fri Sep 15, 2017 11:08 am

Re: Environment vars not reaching event plugin?

Postby mmmancact » Mon Oct 09, 2017 5:42 pm

It's definitely becoming an important tool for a lot of shops. Done well, a lot of configuration could be handled elegantly through it.


Return to “Thinkbox Software - Deadline”

Who is online

Users browsing this forum: No registered users and 1 guest