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()