Skip to content

Commit

Permalink
Merge pull request #7 from ynput/enhancement/refactor_openpype_to_ayon
Browse files Browse the repository at this point in the history
Refactor OpenPype to AYON
  • Loading branch information
jakubjezek001 authored Oct 7, 2024
2 parents 27162cd + 5fe9445 commit 7bba489
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 52 deletions.
8 changes: 3 additions & 5 deletions client/ayon_syncsketch/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import os
from openpype.modules import (
OpenPypeAddOn,
IPluginPaths,
)

from ayon_core.addon import AYONAddon, IPluginPaths
from ayon_syncsketch.common import config
from .version import __version__


SYNCSKETCH_MODULE_DIR = os.path.dirname(os.path.abspath(__file__))


class SyncsketchAddon(OpenPypeAddOn, IPluginPaths):
class SyncsketchAddon(AYONAddon, IPluginPaths):
name = "syncsketch"
enabled = True
version = __version__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def process(self, context):
self.log.debug(project_id)

if project_id:
context.data["syncsketchProjectId"] = project_id
context.data["syncsketchProjectId"] = project_id
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CollectActiveServerConfig(pyblish.api.ContextPlugin):
def process(self, context):
try:
syncsketch_addon = (
context.data.get("openPypeModules")["syncsketch"])
context.data.get("ayonAddons")["syncsketch"])
except AttributeError:
self.log.error("Cannot get Ayon SyncSketch addon.")
raise AssertionError("Ayon SyncSketch addon not found.")
Expand Down
11 changes: 4 additions & 7 deletions client/ayon_syncsketch/plugins/publish/integrate_reviewables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
from copy import deepcopy
from pprint import pformat
import pyblish.api
from openpype.pipeline import KnownPublishError
from openpype.pipeline.publish import (
OpenPypePyblishPluginMixin
)
from openpype.lib import (
from ayon_core.pipeline import KnownPublishError, AYONPyblishPluginMixin
from ayon_core.lib import (
StringTemplate,
BoolDef,
filter_profiles,
prepare_template_data
)
from openpype_modules.ayon_syncsketch.common.server_handler import ServerCommunication # noqa: E501
import ayon_syncsketch.common.server_handler import ServerCommunication # noqa: E501
import requests


class IntegrateReviewables(pyblish.api.InstancePlugin,
OpenPypePyblishPluginMixin):
AYONPyblishPluginMixin):
"""Integrate SyncSketch reviewables.
Uploads representations as reviewables to SyncSketch.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Validate a SyncSketch connection."""
import pyblish.api
from openpype_modules.ayon_syncsketch.common.server_handler import ServerCommunication # noqa: E501
from ayon_syncsketch.common.server_handler import ServerCommunication # noqa: E501
import requests


Expand Down Expand Up @@ -39,4 +39,5 @@ def process(self, context):
response = server_handler.is_connected()

if not response:
raise requests.exceptions.ConnectionError("SyncSketch connection failed.")
raise requests.exceptions.ConnectionError(
"SyncSketch connection failed.")
27 changes: 14 additions & 13 deletions server/settings/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pydantic import Field, validator
from pydantic import validator

from ayon_server.settings import (
BaseSettingsModel,
SettingsField,
ensure_unique_names
)
from ayon_server.settings.enum import secrets_enum
Expand All @@ -13,48 +14,48 @@


class StatusesMapping(BaseSettingsModel):
name: str = Field(
name: str = SettingsField(
title="SyncSketch Status")
ftrack_status: str = Field(
ftrack_status: str = SettingsField(
title="Frack Status")


class ServerListSubmodel(BaseSettingsModel):
url: str = Field(
url: str = SettingsField(
title="SyncSketch Server URL")
auth_user: str = Field(
auth_user: str = SettingsField(
enum_resolver=secrets_enum,
title="Auth Username")
auth_token: str = Field(
auth_token: str = SettingsField(
enum_resolver=secrets_enum,
title="Auth Token")
account_id: str = Field(
account_id: str = SettingsField(
enum_resolver=secrets_enum,
title="Account ID")
ftrack_url: str = Field(
ftrack_url: str = SettingsField(
title="Ftrack Server URL")
ftrack_api_key: str = Field(
ftrack_api_key: str = SettingsField(
enum_resolver=secrets_enum,
title="Ftrack API Key")
ftrack_username: str = Field(
ftrack_username: str = SettingsField(
enum_resolver=secrets_enum,
title="Ftrack Username")


class SyncsketchSettings(BaseSettingsModel):

syncsketch_server_config: ServerListSubmodel = Field(
syncsketch_server_config: ServerListSubmodel = SettingsField(
default_factory=ServerListSubmodel,
title="SyncSketch server config",
scope=["studio"]
)
statuses_mapping: list[StatusesMapping] = Field(
statuses_mapping: list[StatusesMapping] = SettingsField(
default_factory=list,
title="Statuses Mapping",
description="Map Ftrack and SyncSketch statuses.",
scope=["studio"]
)
publish: PublishPluginsModel = Field(
publish: PublishPluginsModel = SettingsField(
default_factory=PublishPluginsModel,
title="Publish Plugins",
)
Expand Down
25 changes: 13 additions & 12 deletions server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
from pydantic import Field, validator
from pydantic import validator

from ayon_server.settings import (
BaseSettingsModel,
task_types_enum,
SettingsField,
ensure_unique_names
)


class ReviewItemProfile(BaseSettingsModel):
_layout = "collapsed"
name: str = Field("", title="Name")
product_types: list[str] = Field(
name: str = SettingsField("", title="Name")
product_types: list[str] = SettingsField(
default_factory=list, title="Product types"
)
hosts: list[str] = Field(default_factory=list, title="Hosts")
task_types: list[str] = Field(
hosts: list[str] = SettingsField(default_factory=list, title="Hosts")
task_types: list[str] = SettingsField(
default_factory=list,
title="Task types",
enum_resolver=task_types_enum
)
tasks: list[str] = Field(default_factory=list, title="Task names")
list_name_template: str = Field(
tasks: list[str] = SettingsField(default_factory=list, title="Task names")
list_name_template: str = SettingsField(
"", title="Review list name template")
review_item_name_template: str = Field(
review_item_name_template: str = SettingsField(
"", title="Review item name template")


class IntegrateReviewablesModel(BaseSettingsModel):
"""Settings for Integrate SyncSketch reviewable plugin."""

representation_tag: str = Field(
representation_tag: str = SettingsField(
title="Representations' activation tag",
disabled=True,
description=(
Expand All @@ -38,7 +39,7 @@ class IntegrateReviewablesModel(BaseSettingsModel):
"the representation you want to upload to SyncSketch."
)
)
review_item_profiles: list[ReviewItemProfile] = Field(
review_item_profiles: list[ReviewItemProfile] = SettingsField(
default_factory=list,
title="Review item profiles"
)
Expand All @@ -52,7 +53,7 @@ def ensure_unique_names(cls, value):

class PublishPluginsModel(BaseSettingsModel):
IntegrateReviewables: IntegrateReviewablesModel = \
Field(
SettingsField(
default_factory=IntegrateReviewablesModel,
title="Integrate reviewables"
)
Expand All @@ -69,7 +70,7 @@ class PublishPluginsModel(BaseSettingsModel):
"task_types": [],
"tasks": [],
"list_name_template": "Uploads from Ayon",
"review_item_name_template": "{folder[name]} | {subset} | v{version}", # noqa: E501
"review_item_name_template": "{folder[name]} | {subset} | v{version}", # noqa: E501
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion tests/client/ayon_syncsketch/test_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestSyncsketchAddon(BaseTest):
# TODO: this is not up to date and needs to be updated
def test_get_syncsketch_config(self, ayon_module_manager):
def test_get_syncsketch_config(self, ayon_addons_manager):
mock_settings = {
"syncsketch": {
"syncsketch_server_configs": [
Expand Down
3 changes: 1 addition & 2 deletions tests/config_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def set_environment():
env = {
"SYNC_SKETCH_API_KEY": os.getenv("SYNC_SKETCH_API_KEY") or "test",
"USE_AYON_SERVER": os.getenv("USE_AYON_SERVER") or "1",
"OPENPYPE_ROOT": ayon_root,
"OPENPYPE_REPOS_ROOT": ayon_root
"AYON_ROOT": ayon_root,
}

for key, value in env.items():
Expand Down
17 changes: 9 additions & 8 deletions tests/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
sys.path.append(str(client_dir))
sys.path.append(str(client_api_dir))


# basic testing class
class BaseTest:
"""Base class for all tests."""

@pytest.fixture(scope="package")
def ayon_module_manager(self):
def ayon_addons_manager(self):
import ayon_start
from openpype.modules import ModulesManager
from ayon_core.addon import AddonsManager

yield ModulesManager
yield AddonsManager

# This is the pytest fixture that creates a mock server
@pytest.fixture
Expand All @@ -40,15 +41,15 @@ def mock_server(self):

class PublishTest(BaseTest):
@pytest.fixture(scope="package")
def syncsketch_addon(self, ayon_module_manager):
manager = ayon_module_manager()
def syncsketch_addon(self, ayon_addons_manager):
manager = ayon_addons_manager()
yield manager["syncsketch"]

@pytest.fixture(scope="package")
def host_plugins(self, syncsketch_addon):
import pyblish.api
from openpype.pipeline import install_openpype_plugins
install_openpype_plugins(host_name="syncsketch")
from ayon_core.pipeline import install_ayon_plugins
install_ayon_plugins(host_name="syncsketch")

yield pyblish.api.discover()

Expand All @@ -58,7 +59,7 @@ def context(self, syncsketch_addon):

class Context(PyblishContext):
data = {
"openPypeModules": {
"ayonAddons": {
"syncsketch": syncsketch_addon
}
}
Expand Down

0 comments on commit 7bba489

Please sign in to comment.