mirror of
https://github.com/saymrwulf/transformers.git
synced 2026-05-14 20:58:08 +00:00
parent
eebd2c972c
commit
b3d1068951
1 changed files with 8 additions and 9 deletions
|
|
@ -3153,15 +3153,14 @@ class Trainer:
|
|||
self.state.stateful_callbacks[cb_name] = cb_state
|
||||
self.state.save_to_json(os.path.join(output_dir, TRAINER_STATE_NAME))
|
||||
|
||||
if os.path.exists(output_dir):
|
||||
try:
|
||||
os.renames(output_dir, checkpoint_dir)
|
||||
except OSError as e:
|
||||
if e.errno in [errno.ENOTEMPTY, errno.EEXIST]: # Directory/File already exists
|
||||
shutil.rmtree(checkpoint_dir)
|
||||
os.renames(output_dir, checkpoint_dir)
|
||||
else:
|
||||
raise
|
||||
try:
|
||||
os.renames(output_dir, checkpoint_dir)
|
||||
except OSError as e:
|
||||
if e.errno in [errno.ENOTEMPTY, errno.EEXIST]: # Directory/File already exists
|
||||
shutil.rmtree(checkpoint_dir)
|
||||
os.renames(output_dir, checkpoint_dir)
|
||||
else:
|
||||
raise
|
||||
|
||||
if self.args.push_to_hub:
|
||||
self._push_from_checkpoint(checkpoint_dir)
|
||||
|
|
|
|||
Loading…
Reference in a new issue