some fixes

This commit is contained in:
Bill Zorn 2015-12-02 15:17:29 -08:00
parent afd89730ad
commit 34176585b2
1 changed files with 17 additions and 13 deletions

View File

@ -5,11 +5,11 @@ import shutil
def identify_checkpoints(basedir, ident):
cp_infos = []
for path in os.listdir(cpdir):
for path in os.listdir(basedir):
fullpath = os.path.join(basedir, path)
if not os.path.isfile(fullpath):
continue
if not (name[:13] == 'lm_lstm_epoch' and name[-4:] == '.txt'):
if not (path[:13] == 'lm_lstm_epoch' and path[-4:] == '.txt'):
continue
if not ident in path:
continue
@ -33,30 +33,34 @@ def identify_checkpoints(basedir, ident):
return cp_infos
def process_dir(basedir, targetdir, ident, copy_cp = False, verbose = False):
(basepath, basedirname) = os.path.split(basedir)
if basedirname == '':
(basepath, basedirname) = os.path.split(basepath)
cp_infos = identify_checkpoints(basedir, ident)
for (dpath, cpath, (epoch, vloss, temp)) in cp_infos:
if verbose:
print('found dumpfile ' + dpath)
dname = basedir + '_epoch' + epoch + '_' + vloss + '.' + ident + '.' + temp + '.txt'
cname = basedir + '_epoch' + epoch + '_' + vloss + '.t7'
dname = basedirname + '_epoch' + epoch + '_' + vloss + '.' + ident + '.' + temp + '.txt'
cname = basedirname + '_epoch' + epoch + '_' + vloss + '.t7'
tdpath = os.path.join(targetdir, dname)
tcpath = os.path.join(targetdir, cname)
if verbose:
print('cp ' + dpath + ' ' + tdpath)
#shutil.copy(dpath, tdpath)
print(' cp ' + dpath + ' ' + tdpath)
shutil.copy(dpath, tdpath)
if copy_cp:
if os.path.isfile('cpath'):
if os.path.isfile(cpath):
if verbose:
print('cp ' + cpath + ' ' + tcpath)
#shutil.copy(cpath, tcpath)
print(' cp ' + cpath + ' ' + tcpath)
shutil.copy(cpath, tcpath)
if copy_cp and len(cp_infos) > 0:
cmdpath = os.path.join(basedir, 'command.txt')
tcmdpath = os.path.join(targetdir, basedir + '.command')
if os.path.isfile('cpath'):
tcmdpath = os.path.join(targetdir, basedirname + '.command')
if os.path.isfile(cmdpath):
if verbose:
print('cp ' + cmdpath + ' ' + tcmdpath)
#shutil.copy(cmdpath, tcmdpath)
print(' cp ' + cmdpath + ' ' + tcmdpath)
shutil.copy(cmdpath, tcmdpath)
for path in os.listdir(basedir):
fullpath = os.path.join(basedir, path)