AWS Thinkbox Discussion Forums

[Deadline scripting] - Accessing Slave Properties

I’m trying to access the slave properties to query and change them. But I can’t find anything in the API that allows this via a Monitor script. Could someone point me in the right direction?

Thanks

if your in the monitor and you want to get of the current slave selection:

slave_info =MonitorUtils.GetSelectedSlaveInfoSettings() slave_settings = MonitorUtils.GetSelectedSlaveSettings()

if your in an event or monitor script and you know the slave_name:

slave_settings = RepositoryUtils.GetSlaveSettings(slave_name, True) slave_info = RepositoryUtils.GetSlaveInfo(slave_name, True)

Hope this helps.
Cheers
Kym

I’ve tried those out but I’m not getting any info back from the MonitorUtils and from the RepositoryUtils I’m getting back a “SlaveSettings” object that I’m not sure what to do with. I really wish I could get autocomplete functionality with the Python API in deadline to help out with this kind of issue. :frowning:

Oh and here is my test code:

[code]from System.IO import *
from Deadline.Scripting import *
from Deadline.Jobs import *
from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog

def main():
print ("----")
print (“RepositoryUtils.GetSlaveInfoSettings(selectedSlave[0], True)”)
selectedSlave = MonitorUtils.GetSelectedSlaveNames()
for i in RepositoryUtils.GetSlaveInfoSettings(selectedSlave[0], True):
print i.Settings

print ("----")
print ("MonitorUtils.GetSelectedSlaveSettings()")
for i in MonitorUtils.GetSelectedSlaveSettings():
    print i

print ("----")
print ("MonitorUtils.GetSelectedSlaveInfoSettings()")
for i in MonitorUtils.GetSelectedSlaveInfoSettings():
    print i[/code]

Also, for some further context if it helps. The info I’m trying to get is the Slave Description and Comment box values.

Hello,

I have adjusted your script:


from System.IO import *
from Deadline.Scripting import *
from Deadline.Jobs import *
from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog


def __main__():    
	print ("----")

	selectedSlaves = MonitorUtils.GetSelectedSlaveNames()

	for slave_name in selectedSlaves:

		print 'got:', slave_name
		slave_settings = RepositoryUtils.GetSlaveSettings(slave_name, True)
		#
		print 'SlaveDescription:',slave_settings.SlaveDescription
		print 'SlaveComment :',slave_settings.SlaveComment

output:

2017-05-15 17:54:25:  PYTHON: ----
2017-05-15 17:54:25:  PYTHON: got: w6201
2017-05-15 17:54:25:  PYTHON: SlaveDescription: i eat frames for lunch
2017-05-15 17:54:25:  PYTHON: SlaveComment : no transcoding

this script i have lives in :
Repolocation/custom/scripts/Slaves/my_sample_script.py

Let me know if you want me to explain this further.
Cheers
Kym

Thank you! I was also able to find where in the documentation these methods live for future reference.

docs.thinkboxsoftware.com/produc … 25f6de4bd4

I actually do have one question. I see in the docs that it says they are Get & Set. But I don’t see how to actually set them…which I will need to do as well.

Hi,

So the ones that are get and set are functions with a Property decorator (I think):
docs.python.org/2/library/funct … l#property

You use them like:

A get is done with no arguments:

slave_desc = slave_settings.SlaveDescription

a set is done by provideding an argument:

slave_settings.SlaveDescription = "Dedicated playblast machine" 

*edit fixed up the set example. copy and pasted from the wrong code :wink:

Ahh perfect thanks! So it’s basically a Deadline variable not a method.

Sorry to keep coming back to this well, but I am stumped on one last issue. So the way to set those variables seems to work for the selected slave in the Monitor. But what if I want to set the property for a non-selected slave?

For example, here I am setting the non-selected slaves Groups.

RepositoryUtils.SetGroupsForSlave("Render01", slaveGroups)

What I am doing is making a script that launches a specified number of slave instances from my selected slave. But I want to give the same properties and attributes of the selected slave to the slave instances.

Example?:
github.com/ThinkboxSoftware/Dea … utoconf.py

Now, to pre-pop those params, you need to create a SlaveSettings object with the assumed name of the Slave that’ll come up. We do this with the SPOT plugin in 9 and the Balancer (using the core APIs). They’ll show up in the Monitor in a blue colour since it’s missing the missing the matching SlaveInfo object.

I’ll admit that I’m unsure how to go about that Edwin. Could you give me a bit more guidance? I can see how to go about setting the params for existing slaves. But I also see what you mean how it takes some time to initialize the new slave instances.

Ah, so the trick here is that if the SlaveSettings object doesn’t exist yet, the GetSlaveSettings() will return a new empty object that you can populate with whatever you want. As long as you properly predict what the new Slave will be named (including suffix), you should be able to pre-define its information.

Here’s another example that I should have pointed you to first, since this doesn’t even require the Slave to be starting up:
github.com/ThinkboxSoftware/Dea … rideIPs.py

If you run that script, you’ll get three brand-new blue Slaves with those names in your Slave list in the Monitor.

Great! Thanks all for the help. I’d like to share the fruits of my labor since I feel this was a community effort. :slight_smile:

Our Bitbucket repositories are private so I can’t share that. But I’ve attached the script to this post.

Cheers!
InstanceManager.rar (1.49 KB)

Privacy | Site terms | Cookie preferences