access PDG_DIR in PythonScript Top when Evaluate In Process

   1875   5   2
User Avatar
Member
76 posts
Joined: March 2007
Offline
Hi there,

At the moment I'm modifying the code in a PythonScript Top from running “external” to “in process”.
I was presuming that using:
print __PDG_DIR__
would be the replacement for:
print os.environ['PDG_DIR']

But apparently it isn't as it errors that __PDG_DIR__ is not defined.
The solution can't be difficult right?

cheers,
benS
User Avatar
Member
76 posts
Joined: March 2007
Offline
…the benefits of using the (default) Evaluate In Process are:
- faster because PDG doesn't need to start separate sessions
- uses same Python environment as your Houdini session rather than a vanilla Python session

I'm using In Process whenever I can..
Just can't imagine the __PDG_DIR__ isn't available in an easy way.

cheers,
benS
User Avatar
Staff
387 posts
Joined: Aug. 2017
Offline
__PDG_DIR__ is the TOP network's working directory, as specified on the scheduler for that node. Therefore, to resolve it you will need to call:

self.scheduler.localizePath('__PDG_DIR__')
User Avatar
Member
76 posts
Joined: March 2007
Offline
Thanks Brandon,

That will do.

I must say it takes quite some time to get grip on the different modes PDG can run in.
For instance this Python Script Top can run in Dynamic or Static and can run out-of-process and in-process.
Each with their different syntax when it comes to attributes, inputs, results and variables.

But I still like PDG a lot!

cheers,
benS
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
ben5ch
Thanks Brandon,
Each with their different syntax when it comes to attributes, inputs, results and variables.
benS

The good news is that H18 makes large improvements in this area.
User Avatar
Member
76 posts
Joined: March 2007
Offline
Hi Chris,

Yes I had a sneak peak at H18 already.

In H17.5 I had just figured out I needed to add the following to my script:
work_item.addResultData(work_item.inputResultData[0][0],work_item.inputResultData[0][1],work_item.inputResultData[0][2])
(yes that can be more compact maybe and does only copy the first input file)

So I was happy to see I the new Copy Inputs To Outputs parameter in H18.
I don't have time to take a deeper look yet.

cheers,
benS
  • Quick Links