AWS Thinkbox Discussion Forums

Issue with SlaveExtraInfoDictionary

Heya, there seems to be an issue with the getter for SlaveExtraInfoDictionary. In the documentation the function is means to return a Dictionary<string, string> but instead returns a type <class ‘System.Collections.Generic.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]’>.

I know it is a reference to the dictionary its also impossible and so convoluted to evaluate likely due to my relative inexperience in python but either way. The only way I have found to evaluate this is with this:

slave_settings = RepositoryUtils.GetSlaveSettings(slave_name, True)
ExtraInfoDict = {}

for field in list(slave_settings.SlaveExtraInfoDictionary):
. . . row = str(field).replace("[", “”)
. . . row = row.replace("]", “”)
. . . row = row.split(", ")
. . . ExtraInfoDict[row[0]] = row[1]

What is the better way to do this and set a variable to equal the underlying dictionary? It’s incredibly annoying as all the other getters for the extra info fields simply return strings so I don’t understand why this doesn’t return a dictionary. Good bye 3 hours of my time… :frowning:


Even worse (or better depending how you look at it) but there’s a function for that kinda. There are two separate getters for the ExtraInfoDictionary, the normal SlaveExtraInfoDictionary which lead me down the above hole, and GetSlaveExtraInfoKeys(). You can then loop through the keys and recreate the dictionary with GetSlaveExtraInfoKeyValue(key). Hazzah

Hey Stephen! You found a fun edge case here. The Dictionary you see there isn’t a Python Dictionary but a C# dictionary so much adventrues in fixing that.

Here’s an equivalent that you can run via DeadlineCommand

from Deadline.Scripting import RepositoryUtils

def __main__(**kargs):
        worker_settings = RepositoryUtils.GetSlaveSettings("<worker name goes here>", True)
        info_dict = worker_settings.SlaveExtraInfoDictionary

        for key, value in info_dict.items():
                print("key: {}, value: {}".format(key, value))

You’re doing the right thing now with GetSlaveExtraInfoKeyValue()!

1 Like

Hey Eamsler,
That is really interesting. Wish I knew more about coding to actually be able to fix rather than work around but that just comes with time. Is it meant to be a python dictionary or is the current function working as intended?

@eamsler FYI, issues also occur with at least some functions that return time data types such as task.TaskRenderTime where it returns a system.TimeSpan rather than datetime.datetime. Not too much of an issue as you can convert it to a string to then convert to a datetime object with datetime.strptime() BUT the precision of milliseconds of the TimeSpan Object is 7 decimals places whereas datetime can only handle 6 decimal places so you have to remove the last character for it to function properly in datetime.strptime(). Once again, likely that I’m over complicating things but that’s what I was able to find.

It’s hard to say if it’s “as intended”. Our API needs some changes so I’ll see if we can’t get these little fixes bundled with a larger efforts on the backlog. No guarantees on when it’ll start though.

Yeah, apologies, intended was not the best wording but I hope you got the gist. Thanks and sounds good.

Privacy | Site terms | Cookie preferences