Skip to content

Commit

Permalink
Merge branch 'feature' of https://github.com/timsergeeff/ayon-kitsu i…
Browse files Browse the repository at this point in the history
…nto feature
  • Loading branch information
timsergeeff committed Oct 29, 2024
2 parents 8abe493 + d887d10 commit bd7ed98
Show file tree
Hide file tree
Showing 22 changed files with 322 additions and 74 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pr_linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 📇 Code Linting

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number}}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
12 changes: 12 additions & 0 deletions .github/workflows/release_trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 🚀 Release Trigger

on:
workflow_dispatch:

jobs:
call-release-trigger:
uses: ynput/ops-repo-automation/.github/workflows/release_trigger.yml@main
secrets:
token: ${{ secrets.YNPUT_BOT_TOKEN }}
email: ${{ secrets.CI_EMAIL }}
user: ${{ secrets.CI_USER }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__
.vscode
poetry.lock
package/
package.py

frontend/node_modules
frontend/dist
Expand Down
7 changes: 6 additions & 1 deletion client/ayon_kitsu/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,20 @@ def get_plugin_paths(self):

return {
"publish": self.get_publish_plugin_paths(),
"hooks": self.get_launch_hook_paths(),
#"hooks": self.get_launch_hook_paths(),
# The laucher action is not working since AYON conversion
# "actions": [os.path.join(KITSU_ROOT, "plugins", "launcher")],
}

def get_publish_plugin_paths(self, host_name=None):
return [os.path.join(KITSU_ROOT, "plugins", "publish")]
<<<<<<< HEAD
def get_launch_hook_paths(self, host_name=None):
return [os.path.join(KITSU_ROOT, "hooks")]
=======
#def get_launch_hook_paths(self, host_name=None):
#return [os.path.join(KITSU_ROOT, "hooks")]
>>>>>>> d887d10b4d525b36a7ed45da66e15005f89c4d76

def is_kitsu_enabled_in_settings(project_settings):
"""Check if kitsu is enabled in kitsu project settings.
Expand Down
4 changes: 3 additions & 1 deletion client/ayon_kitsu/kitsu_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def closeEvent(self, event):
def _on_ok_click(self):
# Check if is connectable
if not self._connectable:
self._message_label.setText("Please set server url in Studio Settings!")
self._message_label.setText(
"Please set server url in Studio Settings!"
)
return

# Collect values
Expand Down
7 changes: 5 additions & 2 deletions client/ayon_kitsu/plugins/publish/integrate_kitsu_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def process(self, context):

# Check if any status condition is not met
allow_status_change = True
for status_cond in self.status_change_conditions["status_conditions"]:
for status_cond in (
self.status_change_conditions["status_conditions"]
):
condition = status_cond["condition"] == "equal"
match = status_cond["short_name"].upper() == shortname
if match and not condition or condition and not match:
Expand Down Expand Up @@ -141,7 +143,8 @@ def process(self, context):
self.log.info(f"Note Kitsu status: {note_status}")
else:
self.log.info(
f"Cannot find {self.note_status_shortname} status. The status will not be changed!"
f"Cannot find {self.note_status_shortname} status."
" The status will not be changed!"
)

# Get comment text body
Expand Down
4 changes: 3 additions & 1 deletion client/ayon_kitsu/plugins/publish/integrate_kitsu_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def process(self, instance):
# Check comment has been created
comment_id = instance.data.get("kitsuComment", {}).get("id")
if not comment_id:
self.log.debug("Comment not created, review not pushed to preview.")
self.log.debug(
"Comment not created, review not pushed to preview."
)
return

kitsu_task = instance.data.get("kitsuTask")
Expand Down
4 changes: 4 additions & 0 deletions client/ayon_kitsu/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
"""Package declaring kitsu addon version."""
<<<<<<< HEAD
__version__ = "1.2.4-appstart.25"
=======
__version__ = "1.2.4-dev.1"
>>>>>>> d887d10b4d525b36a7ed45da66e15005f89c4d76
16 changes: 10 additions & 6 deletions create_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import subprocess
import sys
import zipfile
from typing import Any, Iterable, Optional, Pattern
from typing import Iterable, Optional, Pattern

import package

Expand Down Expand Up @@ -106,7 +106,7 @@ def _extract_member(self, member, tpath, pwd):
else:
tpath = "\\\\?\\" + tpath

return super(ZipFileLongPaths, self)._extract_member(member, tpath, pwd)
return super()._extract_member(member, tpath, pwd)


def safe_copy_file(src_path: str, dst_path: str):
Expand Down Expand Up @@ -192,7 +192,9 @@ def _get_yarn_executable():
if platform.system().lower() == "windows":
cmd = "where"

for line in subprocess.check_output([cmd, "yarn"], encoding="utf-8").splitlines():
for line in subprocess.check_output(
[cmd, "yarn"], encoding="utf-8"
).splitlines():
if not line or not os.path.exists(line):
continue
try:
Expand Down Expand Up @@ -359,7 +361,9 @@ def copy_client_code(output_dir: str, log: logging.Logger):
shutil.rmtree(full_output_dir)

if os.path.exists(full_output_dir):
raise RuntimeError(f"Failed to remove target folder '{full_output_dir}'")
raise RuntimeError(
f"Failed to remove target folder '{full_output_dir}'"
)

os.makedirs(output_dir, exist_ok=True)
mapping = _get_client_zip_content(log)
Expand Down Expand Up @@ -403,7 +407,7 @@ def main(
log.info("Creating client folder")
if not output_dir:
raise RuntimeError(
"Output directory must be defined"
"Output directory must be defined"
" for client only preparation."
)
copy_client_code(output_dir, log)
Expand All @@ -429,7 +433,7 @@ def main(
failed = False
finally:
if failed and os.path.isdir(addon_output_dir):
log.info(f"Purging output dir after failed package creation")
log.info("Purging output dir after failed package creation")
shutil.rmtree(output_dir)

# Skip server zipping
Expand Down
4 changes: 4 additions & 0 deletions package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name = "kitsu"
title = "Kitsu"
<<<<<<< HEAD
version = "1.2.4-appstart.25"
=======
version = "1.2.4-dev.1"
>>>>>>> d887d10b4d525b36a7ed45da66e15005f89c4d76
client_dir = "ayon_kitsu"

services = {
Expand Down
79 changes: 79 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
"tests/*"
]

# Same as Black.
line-length = 79
indent-width = 4

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F", "W"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.per-file-ignores]
"tests/*" = ["F811"]
"server/settings/*" = ["E501"]

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"
10 changes: 8 additions & 2 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ async def setup(self):
# Endpoints
#

async def sync(self, user: CurrentUser, project_name: str) -> EmptyResponse:
async def sync(
self,
user: CurrentUser,
project_name: str
) -> EmptyResponse:
await sync_request(project_name, user)

async def push(
Expand Down Expand Up @@ -88,7 +92,9 @@ async def remove(
payload=payload,
)

async def list_pairings(self, mock: bool = False) -> list[PairingItemModel]:
async def list_pairings(
self, mock: bool = False
) -> list[PairingItemModel]:
await self.ensure_kitsu(mock)
return await get_pairing_list(self)

Expand Down
17 changes: 13 additions & 4 deletions server/kitsu/addon_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
minimal dependencies, pytest unit tests
"""

def required_values(entity: dict[str, Any], keys: list[str], allow_empty_value: bool = False) -> list[Any]:
def required_values(
entity: dict[str, Any],
keys: list[str],
allow_empty_value: bool = False
) -> list[Any]:
"""check the entity dict has the required keys and a value for each"""
values = []
for key in keys:
if key not in entity:
raise ValueError(f"Key '{key}' not set for entity: {entity}")
if not allow_empty_value and not entity.get(key):
raise ValueError(f"Value for '{key}' cannot be empty for entity: {entity}")
raise ValueError(
f"Value for '{key}' cannot be empty for entity: {entity}"
)
values.append(entity.get(key))
return values

Expand Down Expand Up @@ -46,7 +52,9 @@ def to_username(first_name: str, last_name: str | None = None) -> str:
"""converts usernames from kitsu - converts accents"""

name = (
f"{first_name.strip()}.{last_name.strip()}" if last_name else first_name.strip()
f"{first_name.strip()}.{last_name.strip()}"
if last_name
else first_name.strip()
)

name = name.lower()
Expand Down Expand Up @@ -88,7 +96,8 @@ def remove_accents(input_str: str) -> str:

def to_entity_name(name: str) -> str:
r"""convert names so they will pass AYON Entity name validation
@see ayon_server.types.NAME_REGEX = r"^[a-zA-Z0-9_]([a-zA-Z0-9_\.\-]*[a-zA-Z0-9_])?$"
@see ayon_server.types.NAME_REGEX
r"^[a-zA-Z0-9_]([a-zA-Z0-9_\.\-]*[a-zA-Z0-9_])?$"
"""

if not name:
Expand Down
10 changes: 7 additions & 3 deletions server/kitsu/anatomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ async def parse_task_types(
return result


async def parse_statuses(addon: "KitsuAddon", kitsu_project_id: str) -> list[Status]:
async def parse_statuses(
addon: "KitsuAddon", kitsu_project_id: str
) -> list[Status]:
"""Map kitsu status to ayon status
Kitsu structure:
Expand Down Expand Up @@ -198,7 +200,9 @@ async def get_kitsu_project_anatomy(
addon: "KitsuAddon",
kitsu_project_id: str,
) -> Anatomy:
kitsu_project_response = await addon.kitsu.get(f"data/projects/{kitsu_project_id}")
kitsu_project_response = await addon.kitsu.get(
f"data/projects/{kitsu_project_id}"
)
if kitsu_project_response.status_code != 200:
raise AyonException("Could not get Kitsu project")

Expand All @@ -213,7 +217,7 @@ async def get_kitsu_project_anatomy(
for key in anatomy_dict["attributes"]:
if key in attributes:
anatomy_dict["attributes"][key]=attributes[key]

#anatomy_dict["attributes"] = attributes
anatomy_dict["statuses"] = statuses
anatomy_dict["task_types"] = task_types
Expand Down
2 changes: 1 addition & 1 deletion server/kitsu/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"shortName": "co",
"icon": "image",
},
}
}
7 changes: 6 additions & 1 deletion server/kitsu/init_pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
from ayon_server.exceptions import ConflictException
from ayon_server.helpers.deploy_project import create_project_from_anatomy
from ayon_server.lib.postgres import Postgres
from ayon_server.types import PROJECT_CODE_REGEX, PROJECT_NAME_REGEX, Field, OPModel
from ayon_server.types import (
PROJECT_CODE_REGEX,
PROJECT_NAME_REGEX,
Field,
OPModel,
)

from .anatomy import get_kitsu_project_anatomy

Expand Down
Loading

0 comments on commit bd7ed98

Please sign in to comment.