From 2f611f85e205a80d77776ed06db624824d20be78 Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Mon, 16 May 2022 09:18:30 -0700 Subject: [PATCH] Mlflowcallback fix nonetype error (#17171) * Fix edge cases TypeError: 'NoneType' object is not callable * fix style --- src/transformers/integrations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/transformers/integrations.py b/src/transformers/integrations.py index 9e68b142b..dcd8bbd25 100644 --- a/src/transformers/integrations.py +++ b/src/transformers/integrations.py @@ -880,7 +880,11 @@ class MLflowCallback(TrainerCallback): def __del__(self): # if the previous run is not terminated correctly, the fluent API will # not let you start a new run before the previous one is killed - if self._auto_end_run and self._ml_flow and self._ml_flow.active_run() is not None: + if ( + self._auto_end_run + and callable(getattr(self._ml_flow, "active_run", None)) + and self._ml_flow.active_run() is not None + ): self._ml_flow.end_run()