Skip to content

Commit 77cb7b6

Browse files
authored
Merge branch 'develop' into task-type-short-name
2 parents aa899cd + e421522 commit 77cb7b6

File tree

5 files changed

+132
-5
lines changed

5 files changed

+132
-5
lines changed

.github/workflows/release_trigger.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@ name: 🚀 Release Trigger
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
draft:
7+
type: boolean
8+
description: "Create Release Draft"
9+
required: false
10+
default: false
11+
release_overwrite:
12+
type: string
13+
description: "Set Version Release Tag"
14+
required: false
515

616
jobs:
717
call-release-trigger:
818
uses: ynput/ops-repo-automation/.github/workflows/release_trigger.yml@main
19+
with:
20+
draft: ${{ inputs.draft }}
21+
release_overwrite: ${{ inputs.release_overwrite }}
922
secrets:
1023
token: ${{ secrets.YNPUT_BOT_TOKEN }}
1124
email: ${{ secrets.CI_EMAIL }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 📤 Upload to Ynput Cloud
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
call-upload-to-ynput-cloud:
10+
uses: ynput/ops-repo-automation/.github/workflows/upload_to_ynput_cloud.yml@main
11+
secrets:
12+
CI_EMAIL: ${{ secrets.CI_EMAIL }}
13+
CI_USER: ${{ secrets.CI_USER }}
14+
YNPUT_BOT_TOKEN: ${{ secrets.YNPUT_BOT_TOKEN }}
15+
YNPUT_CLOUD_URL: ${{ secrets.YNPUT_CLOUD_URL }}
16+
YNPUT_CLOUD_TOKEN: ${{ secrets.YNPUT_CLOUD_TOKEN }}

server/kitsu/anatomy.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import contextlib
22
from typing import TYPE_CHECKING, Any
33

4+
from ayon_server.entities import ProjectEntity
45
from ayon_server.exceptions import AyonException
56
from ayon_server.lib.postgres import Postgres
67
from ayon_server.settings.anatomy import Anatomy
78
from ayon_server.settings.anatomy.statuses import Status
89
from ayon_server.settings.anatomy.task_types import TaskType
10+
from nxtools import logging
911

1012
from .addon_helpers import create_short_name, remove_accents
13+
from .extract_ayon_project_anatomy import extract_ayon_project_anatomy
1114

1215
if TYPE_CHECKING:
1316
from .. import KitsuAddon
@@ -199,6 +202,7 @@ async def get_primary_anatomy_preset() -> Anatomy:
199202
async def get_kitsu_project_anatomy(
200203
addon: "KitsuAddon",
201204
kitsu_project_id: str,
205+
ayon_project: ProjectEntity | None = None,
202206
) -> Anatomy:
203207
kitsu_project_response = await addon.kitsu.get(
204208
f"data/projects/{kitsu_project_id}"
@@ -212,13 +216,29 @@ async def get_kitsu_project_anatomy(
212216
statuses = await parse_statuses(addon, kitsu_project_id)
213217
task_types = await parse_task_types(addon, kitsu_project_id)
214218

215-
anatomy_preset = await get_primary_anatomy_preset()
216-
anatomy_dict = anatomy_preset.dict()
219+
if ayon_project:
220+
anatomy = extract_ayon_project_anatomy(ayon_project)
221+
else:
222+
anatomy = await get_primary_anatomy_preset()
223+
224+
if ayon_project:
225+
prj_name = ayon_project.name
226+
else:
227+
prj_name = "new project"
228+
229+
anatomy_dict = anatomy.dict()
217230
for key in anatomy_dict["attributes"]:
218231
if key in attributes:
219-
anatomy_dict["attributes"][key]=attributes[key]
232+
anatomy_dict["attributes"][key] = attributes[key]
233+
logging.debug(
234+
"updated project",
235+
prj_name,
236+
"anatomy attribute",
237+
key,
238+
"to",
239+
attributes[key],
240+
)
220241

221-
#anatomy_dict["attributes"] = attributes
222242
anatomy_dict["statuses"] = statuses
223243
anatomy_dict["task_types"] = task_types
224244

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""Extract Anatomy object from ayon ProjectEntity.
2+
3+
This file is for the backwards compatibility with Ayon server.
4+
5+
This funciton is a part of the server from version 1.5.1, so we
6+
can remove this file after a grace period.
7+
8+
```
9+
from ayon_server.helpers.extract_anatomy import extract_project_anatomy
10+
```
11+
12+
"""
13+
14+
from typing import Any
15+
from ayon_server.entities import ProjectEntity
16+
from ayon_server.entities.models.submodels import LinkTypeModel
17+
from ayon_server.settings.anatomy import Anatomy
18+
19+
20+
def dict2list(src) -> list[dict[str, Any]]:
21+
return [{"name": k, "original_name": k, **v} for k, v in src.items()]
22+
23+
24+
def process_aux_table(src: list[dict[str, Any]]) -> list[dict[str, Any]]:
25+
"""Process auxiliary table."""
26+
result = []
27+
for data in src:
28+
result.append({**data, "original_name": data["name"]})
29+
return result
30+
31+
32+
def process_link_types(src: list[LinkTypeModel]) -> list[dict[str, Any]]:
33+
"""Convert project linktypes submodel to anatomy-style linktypes."""
34+
result = []
35+
for ltdata in src:
36+
row = {
37+
"link_type": ltdata.link_type,
38+
"input_type": ltdata.input_type,
39+
"output_type": ltdata.output_type,
40+
}
41+
for key in ["color", "style"]:
42+
if value := ltdata.data.get(key):
43+
row[key] = value
44+
result.append(row)
45+
return result
46+
47+
48+
def extract_ayon_project_anatomy(project: ProjectEntity) -> Anatomy:
49+
"""Extract Anatomy object from ayon ProjectEntity."""
50+
51+
templates = project.config.get("templates", {}).get("common", {})
52+
for template_group, template_group_def in project.config.get(
53+
"templates", {}
54+
).items():
55+
if template_group == "common":
56+
continue
57+
templates[template_group] = dict2list(template_group_def)
58+
59+
result = {
60+
"templates": templates,
61+
"roots": dict2list(project.config.get("roots", {})),
62+
"folder_types": process_aux_table(project.folder_types),
63+
"task_types": process_aux_table(project.task_types),
64+
"link_types": process_link_types(project.link_types),
65+
"statuses": process_aux_table(project.statuses),
66+
"tags": process_aux_table(project.tags),
67+
"attributes": project.attrib,
68+
}
69+
70+
return Anatomy(**result)
71+

server/kitsu/push.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ async def sync_project(
330330
return
331331

332332
await addon.ensure_kitsu(mock)
333-
anatomy = await get_kitsu_project_anatomy(addon, entity_id)
333+
anatomy = await get_kitsu_project_anatomy(addon, entity_id, project)
334334
anatomy_data = anatomy_to_project_data(anatomy)
335335

336336
await update_project(project.name, **anatomy_data)
@@ -552,6 +552,13 @@ async def sync_task(
552552
return
553553

554554
logging.info(f"Creating {entity_dict['type']} '{entity_dict['name']}'")
555+
556+
if "task_type_name" not in entity_dict:
557+
logging.warning(
558+
f"Task type not found for {entity_dict['name']}'"
559+
)
560+
return
561+
555562
target_task = await create_task(
556563
project_name=project.name,
557564
folder_id=parent_id,

0 commit comments

Comments
 (0)