Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Kitsu: Use query function from client #3496

Merged
merged 23 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dada2f4
added function which extract project name based on project id
iLLiCiTiT Jul 12, 2022
b4d11d4
use project name function to drop project collection
iLLiCiTiT Jul 12, 2022
ee370cb
change project in session instead of replacing AvalonMongoDB with pym…
iLLiCiTiT Jul 12, 2022
e2920ff
use query functions in sync service
iLLiCiTiT Jul 12, 2022
d393d6c
a little bit more complicated way how to get asset matching zou id
iLLiCiTiT Jul 12, 2022
20c2ced
use query functions in op to zou sync
iLLiCiTiT Jul 12, 2022
96863fa
use query functions in zou to op sync
iLLiCiTiT Jul 12, 2022
767dc3d
a little bit more complicated queries using zou id
iLLiCiTiT Jul 12, 2022
2988af0
added missing import
iLLiCiTiT Jul 12, 2022
5e14a54
fix typo
iLLiCiTiT Jul 12, 2022
e8f30ee
Added typing notation
iLLiCiTiT Jul 12, 2022
a6c029d
skip validation of zou id
iLLiCiTiT Jul 15, 2022
c210c93
changes from comments
iLLiCiTiT Jul 15, 2022
c59a9cb
Fix: shot duplicate name using shot's hierarchy (ep, seq)
Tilix4 Jul 19, 2022
9f41a51
black
Tilix4 Jul 19, 2022
2bf3cf1
Fix wrong name for sequence
Tilix4 Jul 19, 2022
5939588
Change: Asset is put under an AssetType folder
Tilix4 Jul 20, 2022
02cc216
docstring linting line length
Tilix4 Jul 20, 2022
a3144c9
docstring linting line length
Tilix4 Jul 20, 2022
af45aff
docstring linting line length
Tilix4 Jul 20, 2022
480d196
docstring linting line length
Tilix4 Jul 20, 2022
995a584
Merge pull request #3543 from Tilix4/ch_asset_hierarchy
iLLiCiTiT Jul 20, 2022
4530bfe
Merge pull request #3535 from Tilix4/fx_shot_duplicate_name
iLLiCiTiT Jul 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions openpype/modules/kitsu/utils/sync_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import gazu

from openpype.client import (
get_project,
get_assets,
get_asset_by_name
)
from openpype.pipeline import AvalonMongoDB
from .credentials import validate_credentials
from .update_op_with_zou import (
create_op_asset,
set_op_project,
get_kitsu_project_name,
write_project_to_op,
update_op_assets,
)
Expand Down Expand Up @@ -119,17 +125,16 @@ def _update_project(self, data):

# Write into DB
if update_project:
self.dbcon = self.dbcon.database[project_name]
self.dbcon.Session["AVALON_PROJECT"] = project_name
self.dbcon.bulk_write([update_project])

def _delete_project(self, data):
"""Delete project."""
project_doc = self.dbcon.find_one(
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved
{"type": "project", "data.zou_id": data["project_id"]}
)

project_name = get_kitsu_project_name(data["project_id"])

# Delete project collection
self.dbcon.database[project_doc["name"]].drop()
self.dbcon.database[project_name].drop()

# == Asset ==

Expand All @@ -150,7 +155,8 @@ def _new_asset(self, data):
def _update_asset(self, data):
"""Update asset into OP DB."""
set_op_project(self.dbcon, data["project_id"])
project_doc = self.dbcon.find_one({"type": "project"})
project_name = self.dbcon.active_project()
project_doc = get_project(project_name)

# Get gazu entity
asset = gazu.asset.get_asset(data["asset_id"])
Expand All @@ -159,7 +165,7 @@ def _update_asset(self, data):
# Query all assets of the local project
zou_ids_and_asset_docs = {
asset_doc["data"]["zou"]["id"]: asset_doc
for asset_doc in self.dbcon.find({"type": "asset"})
for asset_doc in get_assets(project_name)
if asset_doc["data"].get("zou", {}).get("id")
}
zou_ids_and_asset_docs[asset["project_id"]] = project_doc
Expand Down Expand Up @@ -199,7 +205,8 @@ def _new_episode(self, data):
def _update_episode(self, data):
"""Update episode into OP DB."""
set_op_project(self.dbcon, data["project_id"])
project_doc = self.dbcon.find_one({"type": "project"})
project_name = self.dbcon.active_project()
project_doc = get_project(project_name)

# Get gazu entity
episode = gazu.shot.get_episode(data["episode_id"])
Expand All @@ -208,7 +215,7 @@ def _update_episode(self, data):
# Query all assets of the local project
zou_ids_and_asset_docs = {
asset_doc["data"]["zou"]["id"]: asset_doc
for asset_doc in self.dbcon.find({"type": "asset"})
for asset_doc in get_assets(project_name)
if asset_doc["data"].get("zou", {}).get("id")
}
zou_ids_and_asset_docs[episode["project_id"]] = project_doc
Expand Down Expand Up @@ -249,7 +256,8 @@ def _new_sequence(self, data):
def _update_sequence(self, data):
"""Update sequence into OP DB."""
set_op_project(self.dbcon, data["project_id"])
project_doc = self.dbcon.find_one({"type": "project"})
project_name = self.dbcon.active_project()
project_doc = get_project(project_name)

# Get gazu entity
sequence = gazu.shot.get_sequence(data["sequence_id"])
Expand All @@ -258,7 +266,7 @@ def _update_sequence(self, data):
# Query all assets of the local project
zou_ids_and_asset_docs = {
asset_doc["data"]["zou"]["id"]: asset_doc
for asset_doc in self.dbcon.find({"type": "asset"})
for asset_doc in get_assets(project_name)
if asset_doc["data"].get("zou", {}).get("id")
}
zou_ids_and_asset_docs[sequence["project_id"]] = project_doc
Expand Down Expand Up @@ -299,7 +307,8 @@ def _new_shot(self, data):
def _update_shot(self, data):
"""Update shot into OP DB."""
set_op_project(self.dbcon, data["project_id"])
project_doc = self.dbcon.find_one({"type": "project"})
project_name = self.dbcon.active_project()
project_doc = get_project(project_name)

# Get gazu entity
shot = gazu.shot.get_shot(data["shot_id"])
Expand All @@ -308,7 +317,7 @@ def _update_shot(self, data):
# Query all assets of the local project
zou_ids_and_asset_docs = {
asset_doc["data"]["zou"]["id"]: asset_doc
for asset_doc in self.dbcon.find({"type": "asset"})
for asset_doc in get_assets(project_name)
if asset_doc["data"].get("zou", {}).get("id")
}
zou_ids_and_asset_docs[shot["project_id"]] = project_doc
Expand All @@ -335,14 +344,15 @@ def _new_task(self, data):
"""Create new task into OP DB."""
# Get project entity
set_op_project(self.dbcon, data["project_id"])
project_name = self.dbcon.active_project()

# Get gazu entity
task = gazu.task.get_task(data["task_id"])

# Find asset doc
asset_doc = self.dbcon.find_one(
{"type": "asset", "data.zou.id": task["entity"]["id"]}
)
parent_name = task["entity"]["name"]

asset_doc = get_asset_by_name(project_name, parent_name)

# Update asset tasks with new one
asset_tasks = asset_doc["data"].get("tasks")
Expand All @@ -359,10 +369,11 @@ def _update_task(self, data):

def _delete_task(self, data):
"""Delete task of OP DB."""
set_op_project(self.dbcon, data["project_id"])

set_op_project(self.dbcon, data["project_id"])
project_name = self.dbcon.active_project()
# Find asset doc
asset_docs = [doc for doc in self.dbcon.find({"type": "asset"})]
asset_docs = list(get_assets(project_name))
for doc in asset_docs:
# Match task
for name, task in doc["data"]["tasks"].items():
Expand Down
Loading