1

Update to a multi-entity list field

I have a lot of Asset-entities (in the order of 1000) linked to a shot. Even if I want to link and unlink a new asset to the shot, I need to pass the entire list of assets with one shotgun-update command.  This is very network intensive as well as time-consuming. 

Is there a simple way of modifying(add/delete) the list of these Asset-entities rather than overwriting it every time ?
Example code
mission = sg.find_one("Shot", [ ], ['id', 'assets'])
request = {'request_type':'update', 'entity_type':"Shot", 'entity_id': shotId}
assets = mission['assets'] # This is a list of ~1000 assets.
for asset in assetsToAdd:
    assets.append({'type': 'Asset', 'id': asset['id']);
request['data'] = {'assets': assets} # This request now contains more than 1000 assets. So the update is going to take a lot of time.
shotgun_api.batch([request])

1 comment

  • 0
    Avatar
    Victoria Grey

    Hi Sumeet,

    This functionality is now available in python-api v3.0.30 : https://github.com/shotgunsoftware/python-api/releases/tag/v3.0.30

    Per your batch example, you would only need to add assets which are not already in the field, by adding multi_entity_update_modes to your request variable, like so:

    request['multi_entity_update_modes'] = {'assets':'add'} 

    Looking forward to any feedback you have on this new functionality.

    —Neil

Please sign in to leave a comment.