From 622fd264a2c8ee8e92af43a7d5dfe90cb54fd3f5 Mon Sep 17 00:00:00 2001 From: George Antonopoulos Date: Wed, 8 Jan 2025 17:22:57 +0000 Subject: [PATCH 01/11] Issue: #34 Dev mode fix to load plugins from dev folder instead or OPENRV_ROOT_DIR Load Frames gets frame range from version instead of representation first. --- client/ayon_openrv/addon.py | 9 ++++ .../plugins/load/openrv/load_frames.py | 51 +++++++++++++------ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/client/ayon_openrv/addon.py b/client/ayon_openrv/addon.py index 9c6fa84..ddb3b7b 100644 --- a/client/ayon_openrv/addon.py +++ b/client/ayon_openrv/addon.py @@ -5,6 +5,10 @@ from .version import __version__ OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) +DEV_MODE = bool(os.getenv("AYON_USE_DEV")) +if DEV_MODE: + print("DEV MODE IS ON") + class OpenRVAddon(AYONAddon, IHostAddon, IPluginPaths): @@ -48,6 +52,11 @@ def add_implementation_envs(self, env, app): def get_launch_hook_paths(self, app): if app.host_name != self.host_name: return [] + if DEV_MODE: + # In development mode, use the current directory's hooks + return [ + os.path.join(os.getcwd(), "client/ayon_openrv/hooks") + ] return [ os.path.join(OPENRV_ROOT_DIR, "hooks") ] diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 14b4e7a..ca92560 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -5,6 +5,7 @@ from ayon_core.pipeline import load from ayon_core.pipeline.load import get_representation_path_from_context from ayon_core.lib.transcoding import IMAGE_EXTENSIONS +from ayon_core.lib import Logger from ayon_openrv.api.pipeline import imprint_container from ayon_openrv.api.ocio import ( @@ -15,6 +16,9 @@ import rv +log = Logger.get_logger(__name__) + + class FramesLoader(load.LoaderPlugin): """Load frames into OpenRV""" @@ -28,7 +32,6 @@ class FramesLoader(load.LoaderPlugin): color = "orange" def load(self, context, name=None, namespace=None, data=None): - filepath = self._format_path(context) # Command fails on unicode so we must force it to be strings filepath = str(filepath) @@ -37,6 +40,7 @@ def load(self, context, name=None, namespace=None, data=None): namespace = namespace if namespace else context["folder"]["name"] loaded_node = rv.commands.addSourceVerbose([filepath]) + log.debug(f"Loaded node: {loaded_node}") # update colorspace self.set_representation_colorspace(loaded_node, @@ -97,22 +101,33 @@ def _get_sequence_range(self, context): """ repre_entity = context["representation"] + version = context.get("version") # Only images may be sequences, not videos ext = repre_entity["context"].get("ext") or repre_entity["name"] if f".{ext}" not in IMAGE_EXTENSIONS: + log.debug(f"Extension {ext} not in IMAGE_EXTENSIONS") return - repre_attribs = repre_entity["attrib"] - # Frame range can be set on version or representation. - # When set on representation it overrides version data. - - repre_frame_start = repre_attribs.get("frameStart") - repre_frame_end = repre_attribs.get("frameEnd") - if repre_frame_start is not None and repre_frame_end is not None: - if repre_frame_start != repre_frame_end: - return repre_frame_start, repre_frame_end - # Single frame + # Check version attributes first as they should have the correct frame range + frame_start = None + frame_end = None + + if version: + version_attribs = version.get("attrib", {}) + frame_start = version_attribs.get("frameStart") + frame_end = version_attribs.get("frameEnd") + + # If not in version attributes, check representation attributes + if frame_start is None or frame_end is None: + repre_attribs = repre_entity["attrib"] + frame_start = repre_attribs.get("frameStart") + frame_end = repre_attribs.get("frameEnd") + + if frame_start is not None and frame_end is not None: + if frame_start != frame_end: + log.debug(f"Using frame range: {frame_start}-{frame_end}") + return frame_start, frame_end return # Fallback for image sequence that does not have frame start and frame @@ -128,6 +143,7 @@ def _get_sequence_range(self, context): collection = collections[0] frames = list(collection.indexes) return frames[0], frames[-1] + return def _format_path(self, context): """Format the path with correct frame range. @@ -137,16 +153,18 @@ def _format_path(self, context): /path/to/sequence.1001-1010#.exr """ - sequence_range = self._get_sequence_range(context) if not sequence_range: - return get_representation_path_from_context(context) + path = get_representation_path_from_context(context) + return path context = copy.deepcopy(context) representation = context["representation"] if not representation["attrib"].get("template"): # No template to find token locations for - return get_representation_path_from_context(context) + path = get_representation_path_from_context(context) + log.debug(f"No template found, using direct path: {path}") + return path def _placeholder(key): # Substitute with a long placeholder value so that potential @@ -161,6 +179,7 @@ def _placeholder(key): tokens = { "frame": f"{start}-{end}#", } + log.debug(f"Using tokens: {tokens}") has_tokens = False repre_context = representation["context"] for key, _token in tokens.items(): @@ -170,12 +189,14 @@ def _placeholder(key): # Replace with our custom template that has the tokens set path = get_representation_path_from_context(context) + log.debug(f"Initial path with placeholders: {path}") if has_tokens: for key, token in tokens.items(): if key in repre_context: path = path.replace(_placeholder(key), token) - + + log.debug(f"Final formatted path: {path}") return path def set_representation_colorspace(self, node, representation): From ada2f838bdbc52dfeb3ec80645919ee140fe81f0 Mon Sep 17 00:00:00 2001 From: George Antonopoulos Date: Wed, 8 Jan 2025 17:43:32 +0000 Subject: [PATCH 02/11] remove print statement --- client/ayon_openrv/addon.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/ayon_openrv/addon.py b/client/ayon_openrv/addon.py index ddb3b7b..d4f226a 100644 --- a/client/ayon_openrv/addon.py +++ b/client/ayon_openrv/addon.py @@ -6,10 +6,6 @@ OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) DEV_MODE = bool(os.getenv("AYON_USE_DEV")) -if DEV_MODE: - print("DEV MODE IS ON") - - class OpenRVAddon(AYONAddon, IHostAddon, IPluginPaths): name = "openrv" From ddfe5bb48543ed09db2178a30a6b507e8a10a8d1 Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:40:30 +0000 Subject: [PATCH 03/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index ca92560..7aad64d 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -101,7 +101,7 @@ def _get_sequence_range(self, context): """ repre_entity = context["representation"] - version = context.get("version") + version_entity = context["version"] # Only images may be sequences, not videos ext = repre_entity["context"].get("ext") or repre_entity["name"] From 290f992251fab28f10e761a4d62567518e435473 Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:40:42 +0000 Subject: [PATCH 04/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 7aad64d..4beb28f 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -143,7 +143,6 @@ def _get_sequence_range(self, context): collection = collections[0] frames = list(collection.indexes) return frames[0], frames[-1] - return def _format_path(self, context): """Format the path with correct frame range. From 19a864959b9cbb771f11eed683fec3589ad05762 Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:40:57 +0000 Subject: [PATCH 05/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 4beb28f..9a4b8b4 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -154,8 +154,7 @@ def _format_path(self, context): """ sequence_range = self._get_sequence_range(context) if not sequence_range: - path = get_representation_path_from_context(context) - return path + return get_representation_path_from_context(context) context = copy.deepcopy(context) representation = context["representation"] From 53d45c6de95f158d31960fc534a3e3c2a18099dc Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:41:10 +0000 Subject: [PATCH 06/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 9a4b8b4..8daa42b 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -160,9 +160,8 @@ def _format_path(self, context): representation = context["representation"] if not representation["attrib"].get("template"): # No template to find token locations for - path = get_representation_path_from_context(context) - log.debug(f"No template found, using direct path: {path}") - return path + log.debug(f"No template found, using direct path") + return get_representation_path_from_context(context) def _placeholder(key): # Substitute with a long placeholder value so that potential From e6f88b5e213918486302417dec8b7c0eae58a89f Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:41:29 +0000 Subject: [PATCH 07/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 8daa42b..069a656 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -114,7 +114,7 @@ def _get_sequence_range(self, context): frame_end = None if version: - version_attribs = version.get("attrib", {}) + version_attribs = version["attrib"] frame_start = version_attribs.get("frameStart") frame_end = version_attribs.get("frameEnd") From c9831d816c3e140f2dd0a9585b322703696107c8 Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:16:09 +0000 Subject: [PATCH 08/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 069a656..5c2fa85 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -113,10 +113,9 @@ def _get_sequence_range(self, context): frame_start = None frame_end = None - if version: - version_attribs = version["attrib"] - frame_start = version_attribs.get("frameStart") - frame_end = version_attribs.get("frameEnd") + version_attribs = version_entity["attrib"] + frame_start = version_attribs.get("frameStart") + frame_end = version_attribs.get("frameEnd") # If not in version attributes, check representation attributes if frame_start is None or frame_end is None: From 1912c84763024bc6eaf1af151d23f62bdd8df132 Mon Sep 17 00:00:00 2001 From: George Antonopoulos Date: Thu, 9 Jan 2025 10:37:11 +0000 Subject: [PATCH 09/11] Remove unnecessary dev mode check --- client/ayon_openrv/addon.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/ayon_openrv/addon.py b/client/ayon_openrv/addon.py index d4f226a..8b3c972 100644 --- a/client/ayon_openrv/addon.py +++ b/client/ayon_openrv/addon.py @@ -5,7 +5,6 @@ from .version import __version__ OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) -DEV_MODE = bool(os.getenv("AYON_USE_DEV")) class OpenRVAddon(AYONAddon, IHostAddon, IPluginPaths): name = "openrv" @@ -35,7 +34,7 @@ def get_load_plugin_paths(self, host_name): # inside OpenRV return [os.path.join(loaders_dir, "openrv")] - def add_implementation_envs(self, env, app): + def add_implementation_envs(self, env, _app): """Modify environments to contain all required for implementation.""" # Set default environments if are not set via settings defaults = { @@ -48,11 +47,6 @@ def add_implementation_envs(self, env, app): def get_launch_hook_paths(self, app): if app.host_name != self.host_name: return [] - if DEV_MODE: - # In development mode, use the current directory's hooks - return [ - os.path.join(os.getcwd(), "client/ayon_openrv/hooks") - ] return [ os.path.join(OPENRV_ROOT_DIR, "hooks") ] From 1fece5f6686c57c0a80b8dde30d5d4f70adc54c6 Mon Sep 17 00:00:00 2001 From: George Antonopoulos <125903264+georgeantonopoulos-bcnvisuals@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:41:44 +0000 Subject: [PATCH 10/11] Update client/ayon_openrv/plugins/load/openrv/load_frames.py Co-authored-by: Roy Nieterau --- client/ayon_openrv/plugins/load/openrv/load_frames.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 5c2fa85..8377716 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -110,8 +110,6 @@ def _get_sequence_range(self, context): return # Check version attributes first as they should have the correct frame range - frame_start = None - frame_end = None version_attribs = version_entity["attrib"] frame_start = version_attribs.get("frameStart") From 82125d43bc6bc1d0f507cb44e86d56eaebd21e21 Mon Sep 17 00:00:00 2001 From: George Antonopoulos Date: Thu, 9 Jan 2025 10:49:10 +0000 Subject: [PATCH 11/11] Replace Logger with self.log --- .../plugins/load/openrv/load_frames.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 8377716..9ab17c8 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -5,7 +5,6 @@ from ayon_core.pipeline import load from ayon_core.pipeline.load import get_representation_path_from_context from ayon_core.lib.transcoding import IMAGE_EXTENSIONS -from ayon_core.lib import Logger from ayon_openrv.api.pipeline import imprint_container from ayon_openrv.api.ocio import ( @@ -16,9 +15,6 @@ import rv -log = Logger.get_logger(__name__) - - class FramesLoader(load.LoaderPlugin): """Load frames into OpenRV""" @@ -40,7 +36,7 @@ def load(self, context, name=None, namespace=None, data=None): namespace = namespace if namespace else context["folder"]["name"] loaded_node = rv.commands.addSourceVerbose([filepath]) - log.debug(f"Loaded node: {loaded_node}") + self.log.debug(f"Loaded node: {loaded_node}") # update colorspace self.set_representation_colorspace(loaded_node, @@ -106,7 +102,7 @@ def _get_sequence_range(self, context): # Only images may be sequences, not videos ext = repre_entity["context"].get("ext") or repre_entity["name"] if f".{ext}" not in IMAGE_EXTENSIONS: - log.debug(f"Extension {ext} not in IMAGE_EXTENSIONS") + self.log.debug(f"Extension {ext} not in IMAGE_EXTENSIONS") return # Check version attributes first as they should have the correct frame range @@ -123,7 +119,7 @@ def _get_sequence_range(self, context): if frame_start is not None and frame_end is not None: if frame_start != frame_end: - log.debug(f"Using frame range: {frame_start}-{frame_end}") + self.log.debug(f"Using frame range: {frame_start}-{frame_end}") return frame_start, frame_end return @@ -157,7 +153,7 @@ def _format_path(self, context): representation = context["representation"] if not representation["attrib"].get("template"): # No template to find token locations for - log.debug(f"No template found, using direct path") + self.log.debug(f"No template found, using direct path") return get_representation_path_from_context(context) def _placeholder(key): @@ -173,7 +169,7 @@ def _placeholder(key): tokens = { "frame": f"{start}-{end}#", } - log.debug(f"Using tokens: {tokens}") + self.log.debug(f"Using tokens: {tokens}") has_tokens = False repre_context = representation["context"] for key, _token in tokens.items(): @@ -183,14 +179,14 @@ def _placeholder(key): # Replace with our custom template that has the tokens set path = get_representation_path_from_context(context) - log.debug(f"Initial path with placeholders: {path}") + self.log.debug(f"Initial path with placeholders: {path}") if has_tokens: for key, token in tokens.items(): if key in repre_context: path = path.replace(_placeholder(key), token) - log.debug(f"Final formatted path: {path}") + self.log.debug(f"Final formatted path: {path}") return path def set_representation_colorspace(self, node, representation):