ynput / ayon-shotgrid

A Shotgrid Addon for the Ayon server.
Apache License 2.0
5 stars 8 forks source link

Shotgrid: reviving archived assets is broken #122

Open kalisp opened 2 months ago

kalisp commented 2 months ago

Changelog Description

This PR supports recreation of children Tasks in AYON if deleted Asset is revived in Shotgrid.

Additional info

I don't like this solution too much, open for comments.

Main issue is that revival of assets on SG sends these events (in order) - attribute_change for CHILD task, attribute_change for Asset, revival_entity. If we are processing first attribute_change, it wants to update non existing Task under non existing Asset. Right now this throws new MissingParentError exception, that could be handled specifically.

It fails processing event, it creates new source event on shotgrid.event (there is no way how to create new event on processing topic, imho), which gets put on the end of the queue. Then asset gets recreated, then this new event gets reprocessed (only once), this time hopefully it finds parent asset in AYON, so it finishes successfully (or fails forever).

Testing notes:

  1. create asset and task(s) in AYON
  2. let them be synchronized to SG (easiest to run in this repo service_tools/manage.ps services`)
  3. delete asset in AYON Editor
  4. let it delete asset in SG
  5. go to trash (top right your profile, Trash at the bottom, Asset) image
  6. check if asset and tasks under it got recreated in AYON
ynbot commented 2 months ago

Task linked: AY-5570 shotgrid: reviving archived assets is broken

iLLiCiTiT commented 2 months ago

I am really against re-submitting leeched events in processor, it should not touch leeched events at all. At the first time of processing the event there might be other events changing or removing the same entity, so moving the event to the end of queue is a huge risk. There might be a real reason why parent was not synced, and re-submitting of the event can cause infinite loop of the event. It should be handled at the moment when we find out the parents are missing.

There also might be other services listening to leeched events, and re-submitting the events can cause their failure.

I'm not responsible for this addon, but for me this is no way.

iLLiCiTiT commented 1 month ago

@MilaKudr could you re-test this please?

MilaKudr commented 1 month ago

It is not working for me at the moment, after deleting the task in Ayon I get error messages like: "2024-09-10 17:18:18.531 | update_from_ayon | remove_sg_entity_from_ayon_event | WARNING: Entity 'a82667b96f8711ef8ccdccd9acc131df' does not have a path to remove from Shotgrid.

kalisp commented 1 month ago

It is not working for me at the moment, after deleting the task in Ayon I get error messages like: "2024-09-10 17:18:18.531 | update_from_ayon | remove_sg_entity_from_ayon_event | WARNING: Entity 'a82667b96f8711ef8ccdccd9acc131df' does not have a path to remove from Shotgrid.

That was sorted out.

Currently its waiting for budget as there is a pushback for current implementation.

It shouldn't modify/create new messages, but re-create full folder structure if necessary. That is not trivial because of current code structure.

kalisp commented 2 weeks ago

I tried to rework logic without creating new event just by creating missing parents in the loop. Not most elegant code there though :/.