Sg instance un event daemon plugin not dealing with custom field

Hi all,

I’m sure it’s right in front of me but I can’t see it:

In order to work around the issue of shot status icons not coming through in a pdf, I have set up a custom shot field called “sg_status_text”.
My code populaes this with the sg_status_list names/display value using the native sg_status_list field as the key. When testing the code it all works fine, but inside my event daemon plugin I get errors claiming the sg instance passed into the plugin cannot find the custom field:

Traceback (most recent call last):
  File "D:\pipeline\tools\python\shotgun_events\src\", line 970, in process
    self._callback(self._shotgun, self._logger, event, self._args)
  File "d:/pipeline/tools/python/shotgun_events/plugins\", line 85, in update_status_text
    sg.update("Shot", shot_id, sg_status_text=status_name_dict[new_value])
TypeError: update() got an unexpected keyword argument 'sg_status_text'

If I create a new sg instance it works, but that does not seem efficient.
This is my simplified plugin code:

def update_status_text(sg, logger, event, args):
    ## Set some variables for convenience:
    shot_id = event["meta"]["entity_id"]
    new_value = event["meta"]["new_value"]
    status_name_dict = sg.schema_field_read("Shot","sg_status_list")["sg_status_list"]["properties"]["display_values"]["value"]"new value is {} > {}".format(new_value, status_name_dict[new_value]))

    # do the deed:
    sg.update("Shot", shot_id, sg_status_text=status_name_dict[new_value])

If I change the last line to use a new instance for the api handle (instead of the one passed into the plugin) it all works fine. I.e.:

my_sg = shotgun_api3.Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)
my_sg.update("Shot", shot_id, sg_status_text=status_name_dict[new_value])

Why would the existing api handle not know the custom field? It definitely exists:


Hm this looks strange indeed… but have you tried passing a dictionary instead of keyword args?

sg.update("Shot", shot_id, {"sg_status_text": "bla"})

It somehow seems the sg instance that event daemon is using is different from a “normal” one. Hopefully someone can shed more light, but that’s what I’d try.

1 Like

boom, you nailed it. That works and as expected is heaps faster, hooray.

Thanks (though the mystery remains why the keyword assignment failed)!

Well, it depends on how the called function treats its **kwargs. It might unpack them or use them as a single dict.

But both those api handle instances should be of the same class and thus have the same method that treats it’s args the same way. But obviously that is not the case.

Anyway, I got a solution and am happy for now, thanks again!