From e6bf60cb77c77b871e149ee037e07d200325b1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 28 Jun 2022 16:28:28 +0200 Subject: [PATCH] Addon: fix issue where Shaman checkout directory wasn't used properly Shaman prevents duplicate checkout directories, and communicates the actual location back to the client. This wasn't used by the add-on though, so the Flamenco job definition would point to the wrong files. --- addon/flamenco/operators.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index 6fc7fba3..71b97ffd 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -225,11 +225,12 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): prefs = preferences.get(context) if prefs.is_shaman_enabled: - blendfile_on_farm = self._bat_pack_shaman(context, blendfile) + # self.blendfile_on_farm will be set when BAT created the checkout, + # see _on_bat_pack_msg() below. + self.blendfile_on_farm = None + self._bat_pack_shaman(context, blendfile) else: - blendfile_on_farm = self._bat_pack_filesystem(context, blendfile) - - self.blendfile_on_farm = blendfile_on_farm + self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile) context.window_manager.modal_handler_add(self) wm = context.window_manager @@ -279,7 +280,7 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): def _bat_pack_shaman( self, context: bpy.types.Context, blendfile: Path - ) -> PurePosixPath: + ) -> None: """Use the Manager's Shaman API to submit the BAT pack. :return: the filesystem path of the blend file, for in the render job definition. @@ -308,14 +309,22 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): ), ) - # Having Shaman enabled on the Manager automatically creates a variable - # "jobs" that will resolve to the checkout directory. - return PurePosixPath("{jobs}") / checkout_root / blendfile.name + # We cannot assume the blendfile location is known until the Shaman + # checkout has actually been created. def _on_bat_pack_msg(self, context: bpy.types.Context, msg: _Message) -> set[str]: from .bat import interface as bat_interface if isinstance(msg, bat_interface.MsgDone): + if self.blendfile_on_farm is None: + # Adjust the blendfile to match the Shaman checkout path. Shaman + # may have checked out at a different location than we + # requested. + # + # Having Shaman enabled on the Manager automatically creates a + # variable "jobs" that will resolve to the checkout directory. + self.blendfile_on_farm = PurePosixPath("{jobs}") / msg.output_path + self._submit_job(context) return self._quit(context)