@@ -1027,16 +1027,6 @@ async def misses_actuate():
10271027 misses_succeeded (w , t )))
10281028 asyncio .create_task (actuate_finalize (threads , results , V .groundtruth_update ))
10291029
1030- def isoldfile (x ,subdir ,basewavs ):
1031- return \
1032- np .any ([x .startswith (b + '-' ) and x .endswith ('.wav' ) for b in basewavs ]) or \
1033- x .endswith ('-classify.log' ) or \
1034- '-predicted' in x or \
1035- x .endswith ('-ethogram.log' ) or \
1036- '-missed' in x or \
1037- x .endswith ('-misses.log' ) or \
1038- x == subdir + '.csv'
1039-
10401030def _validation_test_files (files_string , comma = True ):
10411031 if files_string .rstrip (os .sep ) == V .groundtruth_folder .value .rstrip (os .sep ):
10421032 dfs = []
@@ -1137,31 +1127,37 @@ def sequester_stalefiles():
11371127 M .annotated_csvfiles_all = set ([])
11381128 for button in V .nsounds_per_label_buttons :
11391129 button .label = str (0 )
1140- for subdir in filter (lambda x : os .path .isdir (os .path .join (V .groundtruth_folder .value ,x )), \
1141- os .listdir (V .groundtruth_folder .value )):
1130+
1131+ def isoldfile (x ,curdir ,basewavs ):
1132+ return \
1133+ np .any ([x .startswith (b + '-' ) and x .endswith ('.wav' ) for b in basewavs ]) or \
1134+ x .endswith ('-classify.log' ) or \
1135+ '-predicted' in x or \
1136+ x .endswith ('-ethogram.log' ) or \
1137+ '-missed' in x or \
1138+ x .endswith ('-misses.log' ) or \
1139+ x == curdir + '.csv'
1140+
1141+ def _sequester (curdir ):
11421142 dfs = []
1143- for csvfile in filter (lambda x : '-annotated-' in x and x .endswith ('.csv' ), \
1144- os .listdir (os .path .join (V .groundtruth_folder .value , \
1145- subdir ))):
1146- filepath = os .path .join (V .groundtruth_folder .value , subdir , csvfile )
1147- if os .path .getsize (filepath ) > 0 :
1148- dfs .append (pd .read_csv (filepath , header = None , index_col = False ))
1143+ for entry in os .listdir (curdir ):
1144+ if os .path .isdir (os .path .join (curdir , entry )):
1145+ _sequester (os .path .join (curdir , entry ))
1146+ elif '-annotated-' in entry and entry .endswith ('.csv' ):
1147+ filepath = os .path .join (curdir , entry )
1148+ if os .path .getsize (filepath ) > 0 :
1149+ dfs .append (pd .read_csv (filepath , header = None , index_col = False ))
11491150 if dfs :
11501151 df = pd .concat (dfs )
11511152 basewavs = set ([os .path .splitext (x )[0 ] for x in df [0 ]])
1152- oldfiles = []
1153- for oldfile in filter (lambda x : isoldfile (x ,subdir ,basewavs ), \
1154- os .listdir (os .path .join (V .groundtruth_folder .value , \
1155- subdir ))):
1156- oldfiles .append (oldfile )
1153+ oldfiles = [x for x in os .listdir (curdir ) if isoldfile (x , curdir , basewavs )]
11571154 if len (oldfiles )> 0 :
1158- topath = os .path .join (V .groundtruth_folder .value , \
1159- subdir , \
1160- 'oldfiles-' + M .songexplorer_starttime )
1155+ topath = os .path .join (curdir , 'oldfiles-' + M .songexplorer_starttime )
11611156 os .mkdir (topath )
11621157 for oldfile in oldfiles :
1163- os .rename (os .path .join (V .groundtruth_folder .value , subdir , oldfile ), \
1164- os .path .join (topath , oldfile ))
1158+ os .rename (os .path .join (curdir , oldfile ), os .path .join (topath , oldfile ))
1159+
1160+ _sequester (V .groundtruth_folder .value )
11651161 V .groundtruth_update ()
11661162
11671163async def train_actuate ():
@@ -2006,14 +2002,19 @@ async def congruence_actuate():
20062002 all_files = validation_files + test_files
20072003 if '' in all_files :
20082004 all_files .remove ('' )
2009- logfile = os .path .join (V .groundtruth_folder .value ,'congruence.log' )
2005+ timestamp = datetime .strftime (datetime .now (),'%Y%m%dT%H%M%S' )
2006+ congruence_folder = os .path .join (V .groundtruth_folder .value , 'congruence-' + timestamp )
2007+ os .mkdir (congruence_folder )
2008+ logfile = os .path .join (congruence_folder , 'congruence.log' )
20102009 jobid = generic_actuate ("congruence" , logfile ,
20112010 M .congruence_where ,
20122011 M .congruence_ncpu_cores ,
20132012 M .congruence_ngpu_cards ,
20142013 M .congruence_ngigabytes_memory ,
20152014 M .congruence_cluster_flags ,
20162015 "--basepath=" + V .groundtruth_folder .value ,
2016+ "--topath=" + os .path .join (V .groundtruth_folder .value ,
2017+ 'congruence-' + timestamp ),
20172018 "--wavfiles=" + ',' .join (all_files ),
20182019 "--portion=" + V .congruence_portion .value ,
20192020 "--convolve_ms=" + V .congruence_convolve .value ,
@@ -2031,7 +2032,7 @@ async def congruence_actuate():
20312032 threads [0 ] = asyncio .create_task (actuate_monitor (displaystring , results , 0 , \
20322033 lambda l = logfile , t = currtime : recent_file_exists (l , t , False ), \
20332034 lambda l = logfile : contains_two_timestamps (l ), \
2034- lambda l = V . groundtruth_folder . value , t = currtime , r = regex_files ,
2035+ lambda l = congruence_folder , t = currtime , r = regex_files ,
20352036 m = V .congruence_measure .value : congruence_succeeded (l , t , r , m )))
20362037 asyncio .create_task (actuate_finalize (threads , results , V .groundtruth_update ))
20372038
0 commit comments