Skip to content

Commit

Permalink
Make weight download hack compatible with python 2 (PaddlePaddle#3432)
Browse files Browse the repository at this point in the history
  • Loading branch information
willthefrog authored Sep 27, 2019
1 parent 8e400d2 commit 76b24b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions PaddleCV/PaddleDetection/ppdet/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import print_function
from __future__ import unicode_literals

import errno
import os
import shutil
import time
Expand Down Expand Up @@ -57,9 +58,13 @@ def _get_weight_path(path):
weight_path = map_path(path, WEIGHTS_HOME)
lock_path = weight_path + '.lock'
if not os.path.exists(weight_path):
os.makedirs(os.path.dirname(weight_path), exist_ok=True)
try:
os.makedirs(os.path.dirname(weight_path))
except OSError as e:
if e.errno != errno.EEXIST:
raise
with open(lock_path, 'w'): # touch
os.utime(lock_path)
os.utime(lock_path, None)
if trainer_id == 0:
get_weights_path(path)
os.remove(lock_path)
Expand Down

0 comments on commit 76b24b4

Please sign in to comment.