From 60f22957969ee23322b311047ea4fd2f513fd951 Mon Sep 17 00:00:00 2001 From: chenm1 Date: Mon, 8 Jun 2026 09:48:40 -0700 Subject: [PATCH 1/2] feat: [SG-43418] Pass task context and revision_id from Loader to Publisher Replace env-var-based revision ID passing and publisher._set_context() with tk_multi_publish2.show_dialog(context=..., root_item_properties=...) so the Publisher receives task context and am_revision_id directly. --- hooks/tk-desktop_actions.py | 41 +++++++++++++++---------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/hooks/tk-desktop_actions.py b/hooks/tk-desktop_actions.py index bbcc142..375ec3e 100644 --- a/hooks/tk-desktop_actions.py +++ b/hooks/tk-desktop_actions.py @@ -12,7 +12,6 @@ Hook that loads defines all the available actions, broken down by publish type. """ -import os from typing import Any import sgtk @@ -281,39 +280,16 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None: else: raise TankError(f"Invalid entity type for publish: {entity_type}.") - # Use different env var naming for project-level vs task-level contexts - if task_id is not None: - revision_id_env_var = f"TK_FLOWAM_REVISION_ID_{task_id}" - else: - # For project-level contexts, use project ID - project_id = entity_id - revision_id_env_var = f"TK_FLOWAM_REVISION_ID_PROJECT_{project_id}" - - if action_name == "publish": - revision_id = sg_publish_data.get("sg_flow_revision_id") - os.environ[revision_id_env_var] = revision_id - else: - # Clear possible previously existing publish states from an unfinished publish - # (Finished publishes should clear this value) - if revision_id_env_var in os.environ: - os.environ.pop(revision_id_env_var) - # NOTE: the context should be either a Task or a Project entity_ctx = engine.tank.context_from_entity(entity_type, entity_id) # Launch Publisher via its registered engine command callback. + publisher_app = None for cmd_settings in engine.commands.values(): if cmd_settings.get("properties", {}).get("app") is None: continue if cmd_settings["properties"]["app"].name == "tk-multi-publish2": publisher_app = cmd_settings["properties"]["app"] - single_file_mode = ( - action_name == "publish" - and publisher_app.context.flow_project_id is not None - ) - publisher_app.import_module("tk_multi_publish2").show_dialog( - publisher_app, single_file_mode=single_file_mode - ) break else: raise TankError( @@ -321,3 +297,18 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None: "Please ensure tk-multi-publish2 is configured in " "env/includes/desktop/project.yml under 'desktop.project: apps:'" ) + + tk_multi_publish2 = publisher_app.import_module("tk_multi_publish2") + revision_id = sg_publish_data.get("sg_flow_revision_id") + single_file_mode = ( + action_name == "publish" + and publisher_app.context.flow_project_id is not None + ) + tk_multi_publish2.show_dialog( + publisher_app, + context=entity_ctx, + root_item_properties=( + {"am_revision_id": revision_id} if revision_id else None + ), + single_file_mode=single_file_mode, + ) From a3f4e6a10ab980772729dc70696a46374052ea85 Mon Sep 17 00:00:00 2001 From: chenm1 Date: Fri, 17 Jul 2026 17:50:22 -0700 Subject: [PATCH 2/2] Fix loader publish action --- hooks/tk-desktop_actions.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/hooks/tk-desktop_actions.py b/hooks/tk-desktop_actions.py index 375ec3e..dcbe94b 100644 --- a/hooks/tk-desktop_actions.py +++ b/hooks/tk-desktop_actions.py @@ -284,12 +284,24 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None: entity_ctx = engine.tank.context_from_entity(entity_type, entity_id) # Launch Publisher via its registered engine command callback. - publisher_app = None for cmd_settings in engine.commands.values(): if cmd_settings.get("properties", {}).get("app") is None: continue if cmd_settings["properties"]["app"].name == "tk-multi-publish2": publisher_app = cmd_settings["properties"]["app"] + revision_id = sg_publish_data.get("sg_flow_revision_id") + single_file_mode = ( + action_name == "publish" + and publisher_app.context.flow_project_id is not None + ) + publisher_app.import_module("tk_multi_publish2").show_dialog( + publisher_app, + context=entity_ctx, + root_item_properties=( + {"am_revision_id": revision_id} if revision_id else None + ), + single_file_mode=single_file_mode, + ) break else: raise TankError( @@ -297,18 +309,3 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None: "Please ensure tk-multi-publish2 is configured in " "env/includes/desktop/project.yml under 'desktop.project: apps:'" ) - - tk_multi_publish2 = publisher_app.import_module("tk_multi_publish2") - revision_id = sg_publish_data.get("sg_flow_revision_id") - single_file_mode = ( - action_name == "publish" - and publisher_app.context.flow_project_id is not None - ) - tk_multi_publish2.show_dialog( - publisher_app, - context=entity_ctx, - root_item_properties=( - {"am_revision_id": revision_id} if revision_id else None - ), - single_file_mode=single_file_mode, - )