Skip to content

Commit fc0e76a

Browse files
authored
Merge pull request #92 from Tilix4/feature-sync_paired_proj_startup
Feature: Sync paired projects at processor startup
2 parents 1a0cbaf + 6fc9098 commit fc0e76a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

services/processor/processor/fullsync.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ def get_tasks(
4646
return tasks
4747

4848

49-
def full_sync(
49+
def project_full_sync(
5050
parent: "KitsuProcessor", kitsu_project_id: str, project_name: str
5151
):
52+
"""Sync all entities from a Kitsu project to an Ayon project.
53+
54+
Args:
55+
parent (KitsuProcessor): The parent processor
56+
kitsu_project_id (str): The Kitsu project id
57+
project_name (str): The Ayon
58+
"""
5259
start_time = time.time()
5360
logging.info(f"Syncing kitsu project {kitsu_project_id} to {project_name}")
5461

services/processor/processor/processor.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import gazu
99
from nxtools import log_traceback, logging
1010

11-
from .fullsync import full_sync
11+
from .fullsync import project_full_sync
1212
from .update_from_kitsu import (
1313
create_or_update_asset,
1414
create_or_update_concept,
@@ -308,8 +308,18 @@ def set_paired_ayon_project(
308308

309309
def start_processing(self):
310310
logging.info("KitsuProcessor started")
311+
startup = True
311312

312313
while True:
314+
# Sync all paired projects
315+
if startup:
316+
logging.info("Running sync for all paired projects")
317+
for pair in self.pairing_list:
318+
if pair.get("kitsuProjectId") and pair.get("ayonProjectName"):
319+
project_full_sync(self, pair["kitsuProjectId"], pair["ayonProjectName"])
320+
startup = False
321+
322+
# Check for a new sync job
313323
job = ayon_api.enroll_event_job(
314324
source_topic="kitsu.sync_request",
315325
target_topic="kitsu.sync",
@@ -336,7 +346,7 @@ def start_processing(self):
336346
)
337347

338348
try:
339-
full_sync(self, kitsu_project_id, ayon_project_name)
349+
project_full_sync(self, kitsu_project_id, ayon_project_name)
340350

341351
# if successful add the pair to the list
342352
self.set_paired_ayon_project(

0 commit comments

Comments
 (0)