glenn-jocher
commited on
Commit
•
98f4a5a
1
Parent(s):
f796708
runs/exp increment bug fix #344
Browse files- utils/utils.py +2 -2
utils/utils.py
CHANGED
@@ -902,10 +902,10 @@ def output_to_target(output, width, height):
|
|
902 |
def increment_dir(dir, comment=''):
|
903 |
# Increments a directory runs/exp1 --> runs/exp2_comment
|
904 |
n = 0 # number
|
|
|
905 |
d = sorted(glob.glob(dir + '*')) # directories
|
906 |
if len(d):
|
907 |
-
|
908 |
-
n = int(d[:d.find('_')] if '_' in d else d) + 1 # increment
|
909 |
return dir + str(n) + ('_' + comment if comment else '')
|
910 |
|
911 |
|
|
|
902 |
def increment_dir(dir, comment=''):
|
903 |
# Increments a directory runs/exp1 --> runs/exp2_comment
|
904 |
n = 0 # number
|
905 |
+
dir = str(Path(dir)) # os-agnostic
|
906 |
d = sorted(glob.glob(dir + '*')) # directories
|
907 |
if len(d):
|
908 |
+
n = max([int(x[len(dir):x.find('_') if '_' in x else None]) for x in d]) + 1 # increment
|
|
|
909 |
return dir + str(n) + ('_' + comment if comment else '')
|
910 |
|
911 |
|