Mlflowcallback fix nonetype error (#17171)

* Fix edge cases TypeError: 'NoneType' object is not callable

* fix style
This commit is contained in:
Nicolas Brousse 2022-05-16 09:18:30 -07:00 committed by GitHub
parent 95b6bef624
commit 2f611f85e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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