From f27ccf2465c37139beaec503eda78f43a3b4dc73 Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Thu, 25 May 2023 09:38:09 -0400 Subject: [PATCH] Fix psuh_to_hub in Trainer when nothing needs pushing (#23751) --- src/transformers/trainer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index 79f19f0a3423f7..590c5da195351d 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -3699,9 +3699,10 @@ def _push_from_checkpoint(self, checkpoint_folder): commit_message = f"Training in progress, step {self.state.global_step}" else: commit_message = f"Training in progress, epoch {int(self.state.epoch)}" - _, self.push_in_progress = self.repo.push_to_hub( - commit_message=commit_message, blocking=False, auto_lfs_prune=True - ) + push_work = self.repo.push_to_hub(commit_message=commit_message, blocking=False, auto_lfs_prune=True) + # Return type of `Repository.push_to_hub` is either None or a tuple. + if push_work is not None: + self.push_in_progress = push_work[1] except Exception as e: logger.error(f"Error when pushing to hub: {e}") finally: