ynput / ayon-kitsu

Official AYON<->Kitsu intetgration (WIP)
Apache License 2.0
7 stars 4 forks source link

Fully working sync #32

Closed EmberLightVFX closed 5 months ago

EmberLightVFX commented 5 months ago

This PR is a continuation on @scottmcdonnell PR https://github.com/ynput/ayon-kitsu/pull/31 (which in case is a continuation of https://github.com/ynput/ayon-kitsu/pull/28) I made a fork of his fork and pushed a PR to his but I haven't heard anything from him in a week so I decided to push this PR directly to the Ayon repository instead.

This PR completes all expected sync-posibilities from Kitsu to Ayon. All of these entities support full_sync, create, edit and delete events

Project attributes can be edited and projects can also deleted if enabled in settings (disabled by default).

Usernames are generated using {first_name}.{laste_name} lowercased, so Jacob Danell would end up being jacob.danell The email is synced from kitsu. The password gets a default password that's being able to be set in the settings as only admins currently can set passwords for accounts without passwords?

For entities with comments now sync their comments. For shots it also calculates the in/out frame from the metadata.

The code to sync Concepts exist but the current zou version (0.18.7) have a bug where Concept events also executes Assets events that messes things up for us, so that code is commented out and when CGWire have fixed the problem we just need to un-comment the code.

I have also added settings for all new syncing features:

The files I have done any changes with have bin formatted with black, added type annotations, fixed bugs and cleaned up unused codes and imports.

It also includes an updated create_package.py that allows you to automatically upload the plugin to Ayon and reload the server. Super great for fast development :)

The only thing that I couldn't get working is if the user updates an asset-type, task-type or task-status. In kitsu these are project independent. In Ayon these doesn't have any data dict in their instance so it's impossible to match anything that might have changed.

martastain commented 5 months ago

This is a great job! I am still testing, but it looks super promising. I really appreciate the code readability. Just two notes so far:

Do you think you could move tests to a separate directory as mentioned here? https://github.com/ynput/ayon-kitsu/pull/21#issuecomment-1948256591 I think having a pyproject.toml handling just tests in the addon root is a little confusing.

When i tried it with older kitsu (0.17.7) processor throws the following exceptions, which is probably expected, but maybe silent catching would make sense for studios with older kitsu?

    Traceback (most recent call last):
      File "/service/processor/processor.py", line 325, in start_processing
        full_sync(self, kitsu_project_id, ayon_project_name)
      File "/service/processor/fullsync.py", line 59, in full_sync
        concepts = gazu.concept.all_concepts_for_project(kitsu_project_id)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/gazu/cache.py", line 204, in wrapper
        return function(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/gazu/concept.py", line 33, in all_concepts_for_project
        concepts = raw.fetch_all(
                   ^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/gazu/client.py", line 339, in fetch_all
        return get(url_path_join("data", path), params=params, client=client)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/gazu/client.py", line 206, in get
        check_status(response, path)
      File "/usr/local/lib/python3.11/site-packages/gazu/client.py", line 298, in check_status
        raise RouteNotFoundException(path)
    gazu.exception.RouteNotFoundException: data/projects/fd7bdc19-fdd9-4755-a357-8f8be7c56f4d/concepts
EmberLightVFX commented 5 months ago

Do you think you could move tests to a separate directory as mentioned here? #21 (comment) I think having a pyproject.toml handling just tests in the addon root is a little confusing.

Done! I also updated the test-readme, fixed some test-bugs I found and cleaned up the test-code :)

EmberLightVFX commented 5 months ago

When i tried it with older kitsu (0.17.7) processor throws the following exceptions, which is probably expected, but maybe silent catching would make sense for studios with older kitsu?

Nice find! Concepts were introduced in Kitsu/Zou 0.18.0 Didn't think about this one. I have wrapped concepts around an try/except so you shouldn't get any errors now :)

EmberLightVFX commented 5 months ago

cgwire just fixed the concept event listening in Zou 0.19.0 so I added a check for if the user is running Zou 0.19 or above, in that case start listening for Concepts events :)