Skip to content

Refactor/Sync statuses via listener & sync statuses by kitsu project settings#130

Open
YuanQI295 wants to merge 8 commits into
ynput:developfrom
YuanQI295:sync-status
Open

Refactor/Sync statuses via listener & sync statuses by kitsu project settings#130
YuanQI295 wants to merge 8 commits into
ynput:developfrom
YuanQI295:sync-status

Conversation

@YuanQI295
Copy link
Copy Markdown

Changelog Description

At the pairing of a project from Kitsu to Ayon, all studio statuses were imported into Ayon. This PR imports only the statuses attributed to that specific project. It also syncs any new status added to the Kitsu project in real time, the status appears in Ayon immediately after being added in Kitsu.

Additional review information

The adding of statuses in real time goes through the event called project:update. To test the Sync now button (the safety net in case the processor doesn't sync statuses properly), you need to stop the listener for that event.

Testing notes:

  1. In the Kitsu project Task Status settings, assign some statuses that are specific to that project.
  2. Inside Ayon, pair a new project from Kitsu by clicking Pair project in the Kitsu menu.
  3. Assign a new status to the Kitsu project, then refresh the Ayon page to see the new status available in Ayon.
  4. Comment out the project:update listener in processor.py.
  5. Assign a new status to the Kitsu project, then start a sync from the Sync now button in the Kitsu menu and verify the new status appears in Ayon.

Copy link
Copy Markdown
Contributor

@Sharkitty Sharkitty left a comment

Choose a reason for hiding this comment

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

Generally speaking, when you do a PR, you should indicate if it's a feature, an enhancement or a fix in the PR title. It's even better if it's reflected in the branch name, and the first commit of your branch. I'm not gonna ask you to rename your branch but for next time, keep that in mind (please add that to the PR name though). Don't forget to lint your code. Besides that it's good, only minor things that need to be enhanced imo.

Comment thread server/kitsu/anatomy.py Outdated

async def parse_statuses(
addon: "KitsuAddon", kitsu_project_id: str
addon: "KitsuAddon", kitsu_project_id: str, ayon_project: ProjectEntity | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is too long. In the Ynput repositories, the maximum line length is 79.

Comment thread server/kitsu/anatomy.py Outdated
"""

task_status_response = await addon.kitsu.get("data/task-status")
# Get the statuses from the project instead of studio
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comments should say what your code do, not how you changed the code. If that makes sense? So here you could say it's getting task statuses from project settings, but you should omit that the former implementation was using studio settings.

Comment thread server/kitsu/anatomy.py Outdated

task_status_response = await addon.kitsu.get("data/task-status")
# Get the statuses from the project instead of studio
task_status_response = await addon.kitsu.get(f"data/projects/{kitsu_project_id}/settings/task-status")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line too long and trailing whitespace.

Comment thread server/kitsu/anatomy.py Outdated

# Ensure that status list gets every linked Ayon statuses
if ayon_project:
kitsu_statuses_names = {s.name for s in result}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

only put names in plural, not statuses in that case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

status doesn't take an e in singular

Comment thread server/kitsu/anatomy.py Outdated
# Ensure that status list gets every linked Ayon statuses
if ayon_project:
kitsu_statuses_names = {s.name for s in result}
for existing_status in ayon_project.statuses:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think status would be clear enough as a variable name here.

Comment thread server/kitsu/push.py Outdated
"Person",
"Project",
"SyncCasting",
"TaskStatus"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's best to add a comma , here so next time someone needs to work on this file, they don't need to edit this line to add a new entry.

Comment thread server/kitsu/push.py
entity_dict: "EntityDict",
mock: bool = False,
):
logging.info("sync_project")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you removing logs that are not related to your changes?

Comment thread server/kitsu/push.py Outdated
Comment on lines +848 to +849
elif entity_dict["type"] == "TaskStatus":
if project:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

simpler: elif and project

project_name (str): The Ayon
"""
start_time = time.time()
logging.info(f"Syncing kitsu project {kitsu_project_id} to {project_name}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to remove this either.

@Sharkitty
Copy link
Copy Markdown
Contributor

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

@YuanQI295
Copy link
Copy Markdown
Author

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

I thought the sync now button could stay a security. Per exemple if the processor stopped for a moment, during that time Ayon would not receive any update. We could use the button to catch up ?

@Sharkitty
Copy link
Copy Markdown
Contributor

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

I thought the sync now button could stay a security. Per exemple if the processor stopped for a moment, during that time Ayon would not receive any update. We could use the button to catch up ?

Yeah but why should the processor be stopped manually for this process?

@YuanQI295
Copy link
Copy Markdown
Author

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

I thought the sync now button could stay a security. Per exemple if the processor stopped for a moment, during that time Ayon would not receive any update. We could use the button to catch up ?

Yeah but why should the processor be stopped manually for this process?

I'm not sure I fully understand your question. If the listener is not stopped, the statuses will automatically be added to Ayon, so to simulate a malfunction we could stop the listener?

@Sharkitty
Copy link
Copy Markdown
Contributor

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

I thought the sync now button could stay a security. Per exemple if the processor stopped for a moment, during that time Ayon would not receive any update. We could use the button to catch up ?

Yeah but why should the processor be stopped manually for this process?

I'm not sure I fully understand your question. If the listener is not stopped, the statuses will automatically be added to Ayon, so to simulate a malfunction we could stop the listener?

Ah, so this is just something you need to do for testing then?

@YuanQI295 YuanQI295 changed the title Sync statuses via listener & sync statuses by kitsu project settings Refactor/Sync statuses via listener & sync statuses by kitsu project settings May 27, 2026
@YuanQI295
Copy link
Copy Markdown
Author

One thing I don't really understand however, is why the sync now button requires the listener to be turned off? If I understand correctly, an admin would have to go out of their way to disable it before using this feature. And I think that would be a problem.

I thought the sync now button could stay a security. Per exemple if the processor stopped for a moment, during that time Ayon would not receive any update. We could use the button to catch up ?

Yeah but why should the processor be stopped manually for this process?

I'm not sure I fully understand your question. If the listener is not stopped, the statuses will automatically be added to Ayon, so to simulate a malfunction we could stop the listener?

Ah, so this is just something you need to do for testing then?

yes

@YuanQI295 YuanQI295 requested a review from Sharkitty May 27, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants