Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AY-7217_Add support to sync task assignees and statuses for all entities #113

Merged
merged 22 commits into from
Dec 6, 2024

Conversation

fabiaserra
Copy link
Contributor

@fabiaserra fabiaserra commented Jun 6, 2024

Changelog Description

This adds support to sync task assignees to AYON tasks and statuses on all entities (including Versions)

Testing notes:

  1. synchronize users first
chrome_wk2mdKuBG1 2. Assign users to at least 1 access group in `manageProjects/userSettings?project=YOUR_PROJECT` without it sync of assignees from SG>AYON wont work, but will not fail. Assigning users to AYON project must be implemented during event based user synch. 2. experiment with adding/removing assignee/tags/status in AYON (right column in `Editor`) chrome_gQcwKQRGad
  1. do the same on SG side

(^edited by kalisp)

original PR description kept for posterity

This adds support to sync task assignees to AYON tasks and statuses on all entities (including Versions)

This requires both of these PRs:

AY-7217

Comment on lines 407 to 410
# Why?
# if sg_event["entity_type"] == "Task":
# log.info("Ignoring Task entity.")
# return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, clearer communication was needed. A glitch in the AYON server caused the blockage. @fabiaserra, did it work when you tested it? Which server version are you using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested it and it doesn't seem to be deleting the task even though it's logging as it is:

2024-06-24 14:20:37.849 INFO: Dispatched Ayon event with payload: {'type': 'EventLogEntry', 'id': 36954873, 'event_type': 'Shotgun_Task_Change', 'attribute_name': 'retirement_date', 'meta': {'type': 'attribute_change', 'attribute_name': 'retirement_date', 'entity_type': 'Task', 'entity_id': 113019, 'old_value': None, 'new_value': '2024-06-24 14:20:36 UTC'}, 'entity': None, 'user': {'id': 4556, 'name': 'Fabia Serra Arrizabalaga', 'type': 'HumanUser'}, 'project': {'id': 3909, 'name': 'dev_000', 'type': 'Project'}, 'session_uuid': 'cfb7b296-3234-11ef-bbc3-0a58a9feac02', 'created_at': '2024-06-24T14:20:36+00:00'}
2024-06-24 14:20:37.855 INFO: Dispatched Ayon event with payload: {'type': 'EventLogEntry', 'id': 36954874, 'event_type': 'Shotgun_Task_Retirement', 'attribute_name': None, 'meta': {'entity_type': 'Task', 'class_name': 'Task', 'entity_id': 113019, 'id': 113019, 'type': 'entity_retirement', 'retirement_date': '2024-06-24 14:20:36 UTC', 'display_name': 'light_comp'}, 'entity': None, 'user': {'id': 4556, 'name': 'Fabia Serra Arrizabalaga', 'type': 'HumanUser'}, 'project': {'id': 3909, 'name': 'dev_000', 'type': 'Project'}, 'session_uuid': None, 'created_at': '2024-06-24T14:20:36+00:00'}
2024-06-24 14:20:41.441 INFO: Running the Handler <module 'shotgrid_event'>
2024-06-24 14:20:41.924 INFO: Updating entity from SG event: attribute_change | Task | 113019
2024-06-24 14:20:42.100 WARNING: Entity Task <113019> no longer exists in ShotGrid, aborting...
2024-06-24 14:20:42.100 INFO: Event has been processed... setting to finished!
2024-06-24 14:20:42.144 INFO: Running the Handler <module 'shotgrid_event'>
2024-06-24 14:20:42.382 INFO: Removing entity from SG event: entity_retirement| Task | 113019
2024-06-24 14:20:42.558 INFO: Deleting AYON entity: <TaskEntity - 4b24d7702e5b11efbdd616d3d40dbae9>
2024-06-24 14:20:42.559 INFO: Event has been processed... setting to finished!

Can we fix it?

@mkolar mkolar added the community Issues and PRs coming from the community members label Aug 7, 2024
@fabiaserra fabiaserra mentioned this pull request Oct 3, 2024
7 tasks
@antirotor antirotor added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member labels Nov 28, 2024
Resolved conflicts
@jakubjezek001 jakubjezek001 changed the title Add support to sync task assignees and statuses for all entities AY-7217_Add support to sync task assignees and statuses for all entities Dec 3, 2024
Endpoint queries DB for user with matchin sg_user_id and uses its name as assignee
sg_entity.get(sg_attrib) might return empty ('' or []) which is valid value, so no need to query `sg_{sg_attrib}` which will be None.
Solves completely removing tags from item in SG >> removing them in AYON
It assumes that users are synchronized with SG first, eg. they have data["sg_user_id"]
@kalisp
Copy link
Member

kalisp commented Dec 4, 2024

Fixed conflicts, translated SG user ids to AYON users and back.

Tested synchronizations from SG>AYON and back, it seems to work.

server/__init__.py Outdated Show resolved Hide resolved
"Status with short name '%s' doesn't exist in project", status
)
else:
try:
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check for scope of the status before you set it -> try except block would not be needed.

Copy link
Member

@jakubjezek001 jakubjezek001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kalisp kalisp merged commit 4197397 into ynput:develop Dec 6, 2024
1 check passed
@kalisp
Copy link
Member

kalisp commented Dec 6, 2024

Let test more before release.

Thanks Fabia for contribution, even if it took a for while to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor community Issues and PRs coming from the community members sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants