From ea91a4e44e03b7ba3d6fd74fe25b3e051ab08dfa Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Mon, 13 Feb 2023 20:19:24 +0530 Subject: [PATCH 1/5] Account for the instance of submodules.pack.Packer --- addon/flamenco/bat/interface.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/addon/flamenco/bat/interface.py b/addon/flamenco/bat/interface.py index 4a26804a..56e845fe 100644 --- a/addon/flamenco/bat/interface.py +++ b/addon/flamenco/bat/interface.py @@ -8,7 +8,7 @@ import logging import queue import threading import typing - +import traceback from . import submodules log = logging.getLogger(__name__) @@ -54,6 +54,12 @@ class MsgDone(Message): missing_files: list[Path] +@dataclass +class MsgDoneNotShaman(Message): + output_path: Path + missing_files: list[Path] + + # MyPy doesn't understand the way BAT subpackages are imported. class BatProgress(submodules.progress.Callback): # type: ignore """Report progress of BAT Packing to the given queue.""" @@ -149,6 +155,7 @@ class PackThread(threading.Thread): except BaseException as ex: log.error("Error packing with BAT: %s", ex) self.queue.put(MsgException(ex=ex)) + traceback.print_exc() finally: with _packer_lock: _running_packthread = None @@ -166,11 +173,16 @@ class PackThread(threading.Thread): log.debug("done") self._set_bat_status("DONE") - msg = MsgDone( - self.packer.output_path, - self.packer.actual_checkout_path, - self.packer.missing_files, - ) + if isinstance(self.packer, submodules.pack.Packer): + msg = MsgDoneNotShaman( + self.packer.output_path, self.packer.missing_files + ) + else: + msg = MsgDone( + self.packer.output_path, + self.packer.actual_checkout_path, + self.packer.missing_files, + ) self.queue.put(msg) def _set_bat_status(self, status: str) -> None: -- 2.30.2 From 965b99546a84b2924f16134e6edb202bce63ba7a Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Tue, 14 Feb 2023 10:30:31 +0530 Subject: [PATCH 2/5] Fix: interface.py -> MsgDone class, make `actual_checkout_path` an Optional attribute We need to do so, to handle both cases when object of PackTread class is initialised with `submodules.pack.Packer`(don't have `actual_checkout_length attribute) instance or `bat_shaman.Packer`(have `actual_checkout_length` attribute) instance. --- addon/flamenco/bat/interface.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/addon/flamenco/bat/interface.py b/addon/flamenco/bat/interface.py index 56e845fe..cb34e567 100644 --- a/addon/flamenco/bat/interface.py +++ b/addon/flamenco/bat/interface.py @@ -48,16 +48,10 @@ class MsgProgress(Message): @dataclass class MsgDone(Message): output_path: Path - """Path of the submitted blend file, relative to the Shaman checkout root.""" - actual_checkout_path: PurePosixPath """Shaman checkout path, i.e. the root of the job files, relative to the Shaman checkout root.""" missing_files: list[Path] - - -@dataclass -class MsgDoneNotShaman(Message): - output_path: Path - missing_files: list[Path] + """Path of the submitted blend file, relative to the Shaman checkout root.""" + actual_checkout_path: Optional[PurePosixPath] = None # MyPy doesn't understand the way BAT subpackages are imported. @@ -174,14 +168,12 @@ class PackThread(threading.Thread): self._set_bat_status("DONE") if isinstance(self.packer, submodules.pack.Packer): - msg = MsgDoneNotShaman( - self.packer.output_path, self.packer.missing_files - ) + msg = MsgDone(self.packer.output_path, self.packer.missing_files) else: msg = MsgDone( self.packer.output_path, - self.packer.actual_checkout_path, self.packer.missing_files, + self.packer.actual_checkout_path, ) self.queue.put(msg) -- 2.30.2 From 518e5fc7ba54f126e0e1580c383b6813fe240ad5 Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Tue, 14 Feb 2023 10:35:24 +0530 Subject: [PATCH 3/5] cleanup: remove traceback.print_exc() --- addon/flamenco/bat/interface.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addon/flamenco/bat/interface.py b/addon/flamenco/bat/interface.py index cb34e567..e330c11e 100644 --- a/addon/flamenco/bat/interface.py +++ b/addon/flamenco/bat/interface.py @@ -8,7 +8,6 @@ import logging import queue import threading import typing -import traceback from . import submodules log = logging.getLogger(__name__) @@ -149,7 +148,6 @@ class PackThread(threading.Thread): except BaseException as ex: log.error("Error packing with BAT: %s", ex) self.queue.put(MsgException(ex=ex)) - traceback.print_exc() finally: with _packer_lock: _running_packthread = None -- 2.30.2 From 0abf83b25be97ab417a68381cc6f406d700f8d6f Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Tue, 14 Feb 2023 16:00:53 +0530 Subject: [PATCH 4/5] Simplify code to use `getattr` function Doing so removes the need to check for a particular implementation of `Packer` object using if-else statements. --- addon/flamenco/bat/interface.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/addon/flamenco/bat/interface.py b/addon/flamenco/bat/interface.py index e330c11e..2c945273 100644 --- a/addon/flamenco/bat/interface.py +++ b/addon/flamenco/bat/interface.py @@ -165,14 +165,11 @@ class PackThread(threading.Thread): log.debug("done") self._set_bat_status("DONE") - if isinstance(self.packer, submodules.pack.Packer): - msg = MsgDone(self.packer.output_path, self.packer.missing_files) - else: - msg = MsgDone( - self.packer.output_path, - self.packer.missing_files, - self.packer.actual_checkout_path, - ) + msg = MsgDone( + self.packer.output_path, + self.packer.missing_files, + getattr(self.packer, "actual_checkout_path", None), + ) self.queue.put(msg) def _set_bat_status(self, status: str) -> None: -- 2.30.2 From 810ac355a79175362bd16878aef0315f1e8fb407 Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Tue, 14 Feb 2023 16:23:26 +0530 Subject: [PATCH 5/5] Include the new line which was removed. Formatting changes should have there own PR. --- addon/flamenco/bat/interface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/flamenco/bat/interface.py b/addon/flamenco/bat/interface.py index 2c945273..a6f92a8e 100644 --- a/addon/flamenco/bat/interface.py +++ b/addon/flamenco/bat/interface.py @@ -8,6 +8,7 @@ import logging import queue import threading import typing + from . import submodules log = logging.getLogger(__name__) -- 2.30.2