Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Publisher instead of pyblish pype #19

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
36 changes: 11 additions & 25 deletions client/ayon_harmony/api/TB_sceneOpened.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,22 +395,6 @@ function start() {
var action = menu.addAction('Create...');
action.triggered.connect(self.onCreator);


/**
* Show Workfiles
*/
self.onWorkfiles = function() {
app.ayonClient.send({
'module': 'ayon_harmony.api.lib',
'method': 'show',
'args': ['workfiles']
}, false);
};
if (app.ayonMenu == null) {
action = menu.addAction('Workfiles...');
action.triggered.connect(self.onWorkfiles);
}

/**
* Show Loader
*/
Expand All @@ -434,7 +418,7 @@ function start() {
app.ayonClient.send({
'module': 'ayon_harmony.api.lib',
'method': 'show',
'args': ['publish']
'args': ['publisher']
}, false);
};
// add Publisher item to menu
Expand All @@ -460,19 +444,19 @@ function start() {
}

/**
* Show Subset Manager
*/
self.onSubsetManage = function() {
* Show Workfiles
*/
self.onWorkfiles = function() {
app.ayonClient.send({
'module': 'ayon_harmony.api.lib',
'method': 'show',
'args': ['subsetmanager']
'args': ['workfiles']
}, false);
};
// add Subset Manager item to menu
if (app.ayonMenu == null) {
action = menu.addAction('Subset Manager...');
action.triggered.connect(self.onSubsetManage);
menu.addSeparator();
action = menu.addAction('Workfiles...');
action.triggered.connect(self.onWorkfiles);
}

/**
Expand All @@ -488,8 +472,10 @@ function start() {
false
);
};

// add Set Scene Settings
if (app.ayonMenu == null) {
menu.addSeparator();
action = menu.addAction('Set Scene Settings...');
action.triggered.connect(self.onSetSceneSettings);
}
Expand All @@ -504,8 +490,8 @@ function start() {
'args': ['experimental_tools']
}, false);
};
// add Subset Manager item to menu
if (app.ayonMenu == null) {
menu.addSeparator();
action = menu.addAction('Experimental Tools...');
action.triggered.connect(self.onExperimentalTools);
}
Expand Down
4 changes: 1 addition & 3 deletions client/ayon_harmony/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
from .pipeline import (
ls,
install,
HarmonyHost,
list_instances,
remove_instance,
select_instance,
Expand All @@ -16,7 +16,6 @@
check_inventory,
application_launch,
export_template,
on_pyblish_instance_toggled,
inject_ayon_js,
)

Expand Down Expand Up @@ -60,7 +59,6 @@
"check_inventory",
"application_launch",
"export_template",
"on_pyblish_instance_toggled",
"inject_ayon_js",

# lib
Expand Down
6 changes: 4 additions & 2 deletions client/ayon_harmony/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def launch(application_path, *args):

"""
from ayon_core.pipeline import install_host
from ayon_harmony import api as harmony
from ayon_harmony.api import HarmonyHost

install_host(harmony)
install_host(HarmonyHost())

ProcessContext.port = random.randrange(49152, 65535)
os.environ["AYON_HARMONY_PORT"] = str(ProcessContext.port)
Expand Down Expand Up @@ -401,6 +401,8 @@ def show(tool_name):
kwargs = {}
if tool_name == "loader":
kwargs["use_context"] = True
elif tool_name == "publisher":
kwargs["tab"] = "publish"

ProcessContext.execute_in_main_thread(
lambda: host_tools.show_tool_by_name(tool_name, **kwargs)
Expand Down
64 changes: 64 additions & 0 deletions client/ayon_harmony/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import pyblish.api

from ayon_core.lib import register_event_callback
from ayon_core.host import (
HostBase,
IWorkfileHost,
ILoadHost,
IPublishHost,
)
from ayon_core.pipeline import (
register_loader_plugin_path,
register_creator_plugin_path,
Expand All @@ -18,6 +24,14 @@
from ayon_harmony import HARMONY_ADDON_ROOT
import ayon_harmony.api as harmony

from .workio import (
open_file,
save_file,
current_file,
has_unsaved_changes,
file_extensions,
work_root
)

log = logging.getLogger("ayon_harmony")

Expand All @@ -28,6 +42,53 @@
INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory")


class HarmonyHost(HostBase, IWorkfileHost, ILoadHost):
name = "harmony"

def install(self):
"""Install Pype as host config."""
print("Installing AYON Harmony Host ...")

pyblish.api.register_host("harmony")
pyblish.api.register_plugin_path(PUBLISH_PATH)
register_loader_plugin_path(LOAD_PATH)
register_creator_plugin_path(CREATE_PATH)

register_event_callback("application.launched", application_launch)

def uninstall(self):
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
deregister_loader_plugin_path(LOAD_PATH)
deregister_creator_plugin_path(CREATE_PATH)

def open_workfile(self, filepath):
return open_file(filepath)

def save_workfile(self, filepath=None):
return save_file(filepath)

def work_root(self, session):
return work_root(session)

def get_current_workfile(self):
return current_file()

def workfile_has_unsaved_changes(self):
return has_unsaved_changes()

def get_workfile_extensions(self):
return file_extensions()

def get_containers(self):
return ls()

# def get_context_data(self):
# raise NotImplementedError()
#
# def update_context_data(self, data, changes):
# raise NotImplementedError()


def set_scene_settings(settings):
"""Set correct scene settings in Harmony.

Expand Down Expand Up @@ -246,6 +307,7 @@ def list_instances(remove_orphaned=True):
Returns:
(list) of dictionaries matching instances format
"""
# TODO: Remove this, refactor to new style Creators instead
objects = harmony.get_scene_data() or {}
instances = []
for key, data in objects.items():
Expand Down Expand Up @@ -284,6 +346,7 @@ def remove_instance(instance):
Args:
instance (dict): instance representation from subsetmanager model
"""
# TODO: Remove this, refactor to new style Creators instead
node = instance.get("uuid")
harmony.remove(node)
harmony.delete_node(node)
Expand All @@ -296,6 +359,7 @@ def select_instance(instance):
Args:
instance (dict): instance representation from subsetmanager model
"""
# TODO: Remove this, refactor to new style Creators instead
harmony.select_nodes([instance.get("uuid")])


Expand Down
1 change: 1 addition & 0 deletions client/ayon_harmony/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Creator(LegacyCreator):
If the selection is used, the selected nodes will be connected to the
created node.
"""
# TODO: Refactor to the new creator API

defaults = ["Main"]
node_type = "COMPOSITE"
Expand Down
Loading