@@ -32,7 +32,7 @@ def generic_actuate(cmd, logfile, where,
3232 if platform .system ()== 'Windows' :
3333 cmd = cmd .replace (os .path .sep , os .path .sep + os .path .sep )
3434 args = [x .replace ('<' ,'^^^<' ).replace ('>' ,'^^^>' ) for x in args ]
35- args = [" \' \' " if x == "" else "'" + x + "'" for x in args ]
35+ args = [x . replace ( ' ' , '' ) for x in args ]
3636 with open (logfile , 'w' ) as fid :
3737 fid .write (cmd + " " + ' ' .join (args )+ '\n ' )
3838 localdeps = []
@@ -44,31 +44,47 @@ def generic_actuate(cmd, logfile, where,
4444 for job in M .waitfor_job :
4545 clusterflags += "\" done(" + job + ")\" &&"
4646 clusterflags = clusterflags [:- 2 ]
47+ if M .use_aitch :
48+ aitch_cmd = ["hsubmit" ,
49+ "-o" , logfile , "-e" , logfile , "-a" ,
50+ str (ncpu_cores )+ ',' + str (ngpu_cards )+ ',' + str (ngigabyes_memory ),
51+ * localdeps , "python" ]
52+ kwargs = {"process_group" : 0 } if sys .version_info .major == 3 and sys .version_info .minor >= 11 else {}
4753 if where == "local" :
48- kwargs = {"process_group" : 0 } if sys .version_info .major == 3 and sys .version_info .minor >= 11 else {}
49- p = Popen (["hsubmit" ,
50- "-o" , logfile , "-e" , logfile , "-a" ,
51- str (ncpu_cores )+ ',' + str (ngpu_cards )+ ',' + str (ngigabyes_memory ),
52- * localdeps ,
53- "python" ,
54- cmd + " " + ' ' .join (args )],
55- stdout = PIPE , ** kwargs )
56- jobid = p .stdout .readline ().decode ('ascii' ).rstrip ()
57- bokehlog .info (jobid )
54+ if M .use_aitch :
55+ args = ["\' \' " if x == "" else "'" + x + "'" for x in args ]
56+ p = Popen ([* aitch_cmd , cmd + " " + ' ' .join (args )], stdout = PIPE , ** kwargs )
57+ jobid = p .stdout .readline ().decode ('ascii' ).rstrip ()
58+ bokehlog .info (jobid )
59+ else :
60+ args = filter (lambda x : not x .startswith ("--igpu" ), args )
61+ if M .local_current_job :
62+ M .local_current_job .wait ()
63+ with open (logfile , 'a' ) as fid :
64+ M .local_current_job = Popen ([cmd , * args ], stdout = fid , stderr = fid , ** kwargs )
65+ jobid = ''
5866 elif where == "server" :
59- p = Popen (["ssh" , "-l" , M .server_username , M .server_ipaddr , "export SINGULARITYENV_PREPEND_PATH=" + M .source_path + ";" ,
60- "$SONGEXPLORER_BIN" , "hsubmit" ,
61- "-o" , logfile , "-e" , logfile , "-a" ,
62- str (ncpu_cores )+ ',' + str (ngpu_cards )+ ',' + str (ngigabyes_memory ),
63- * localdeps ,
64- cmd + " " + ' ' .join (args ).replace ('"' ,'\\ "' )],
65- stdout = PIPE )
66- jobid = p .stdout .readline ().decode ('ascii' ).rstrip ()
67- bokehlog .info (jobid )
67+ ssh_cmd = ["ssh" , "-l" , M .server_username , M .server_ipaddr , "export SINGULARITYENV_PREPEND_PATH=" + M .source_path + ";" , "$SONGEXPLORER_BIN" ]
68+ if M .use_aitch :
69+ p = Popen ([* ssh_cmd , * aitch_cmd ,
70+ "'" + cmd + " " + ' ' .join (args ).replace ('"' ,'\\ "' )+ "'" ],
71+ stdout = PIPE , ** kwargs )
72+ jobid = p .stdout .readline ().decode ('ascii' ).rstrip ()
73+ bokehlog .info (jobid )
74+ else :
75+ args = ["\' \' " if x == "" else "'" + x + "'" for x in args ]
76+ args = filter (lambda x : not x .startswith ("--igpu" ), args )
77+ if M .server_current_job :
78+ M .server_current_job .wait ()
79+ with open (logfile , 'a' ) as fid :
80+ M .server_current_job = Popen ([* ssh_cmd , cmd , * args ], stdout = fid , stderr = fid , ** kwargs )
81+ jobid = ''
6882 elif where == "cluster" :
83+ args = filter (lambda x : not x .startswith ("--igpu" ), args )
84+ args = ["\' \' " if x == "" else "'" + x + "'" for x in args ]
6985 pe = Popen (["echo" ,
7086 "export SINGULARITYENV_PREPEND_PATH=" + M .source_path + ";" ,
71- "$SONGEXPLORER_BIN " + cmd + " " + ' ' .join (filter ( lambda x : not x . startswith ( "'--igpu" ), args ) )],
87+ "$SONGEXPLORER_BIN " + cmd + " " + ' ' .join (args )],
7288 stdout = PIPE )
7389 if M .cluster_ipaddr :
7490 ssh_cmd = ["ssh" , M .cluster_ipaddr ]
@@ -950,9 +966,11 @@ async def _detect_actuate(i, wavfiles, threads, results):
950966 "--audio_tic_rate=" + str (M .audio_tic_rate ), \
951967 "--audio_nchannels=" + str (M .audio_nchannels ),
952968 "--audio_read_plugin=" + str (M .audio_read_plugin ),
953- "--audio_read_plugin_kwargs=' " + json .dumps (M .audio_read_plugin_kwargs )+ "'" )
969+ "--audio_read_plugin_kwargs=" + json .dumps (M .audio_read_plugin_kwargs ))
954970 M .waitfor_job .append (jobid )
955- displaystring = "DETECT " + os .path .basename (wavfile )+ " (" + jobid + ")"
971+ displaystring = "DETECT " + os .path .basename (wavfile )
972+ if jobid :
973+ displaystring += " (" + jobid + ")"
956974 threads [i ] = asyncio .create_task (actuate_monitor (displaystring , results , i , \
957975 lambda l = logfile , t = currtime : \
958976 recent_file_exists (l , t , False ), \
@@ -995,7 +1013,9 @@ async def misses_actuate():
9951013 M .misses_ngigabytes_memory ,
9961014 M .misses_cluster_flags , \
9971015 V .wavcsv_files .value )
998- displaystring = "MISSES " + wavfile + " (" + jobid + ")"
1016+ displaystring = "MISSES " + wavfile
1017+ if jobid :
1018+ displaystring += " (" + jobid + ")"
9991019 M .waitfor_job = [jobid ]
10001020 V .waitfor_update ()
10011021 threads , results = [None ], [None ]
@@ -1198,8 +1218,9 @@ async def train_actuate():
11981218 M .train_cluster_flags ,
11991219 * args )
12001220 jobids .append (jobid )
1201- displaystring = "TRAIN " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1202- " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
1221+ displaystring = "TRAIN " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1222+ if jobid :
1223+ displaystring += " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
12031224 M .waitfor_job = jobids
12041225 V .waitfor_update ()
12051226 threads , results = [None ], [None ]
@@ -1285,8 +1306,9 @@ async def leaveout_actuate(comma):
12851306 M .generalize_cluster_flags , \
12861307 * args )
12871308 jobids .append (jobid )
1288- displaystring = "GENERALIZE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1289- " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
1309+ displaystring = "GENERALIZE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1310+ if jobid :
1311+ displaystring += " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
12901312 M .waitfor_job = jobids
12911313 V .waitfor_update ()
12921314 logfile1 = os .path .join (V .logs_folder .value , "generalize1.log" )
@@ -1351,8 +1373,9 @@ async def xvalidate_actuate():
13511373 * args )
13521374 jobids .append (jobid )
13531375
1354- displaystring = "XVALIDATE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1355- " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
1376+ displaystring = "XVALIDATE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1377+ if jobid :
1378+ displaystring += " (" + ',' .join ([str (x ) for x in jobids ])+ ")"
13561379 M .waitfor_job = jobids
13571380 V .waitfor_update ()
13581381 logfile1 = os .path .join (V .logs_folder .value , "xvalidate1.log" )
@@ -1380,8 +1403,9 @@ async def mistakes_actuate():
13801403 M .mistakes_ngigabytes_memory ,
13811404 M .mistakes_cluster_flags ,
13821405 V .groundtruth_folder .value )
1383- displaystring = "MISTAKES " + os .path .basename (V .groundtruth_folder .value .rstrip (os .sep ))+ \
1384- " (" + jobid + ")"
1406+ displaystring = "MISTAKES " + os .path .basename (V .groundtruth_folder .value .rstrip (os .sep ))
1407+ if jobid :
1408+ displaystring += " (" + jobid + ")"
13851409 M .waitfor_job = [jobid ]
13861410 V .waitfor_update ()
13871411 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1444,8 +1468,9 @@ async def activations_actuate():
14441468 * args )
14451469
14461470 displaystring = "ACTIVATIONS " + \
1447- os .path .join (os .path .basename (logdir ), model , "ckpt-" + check_point ) + \
1448- " (" + jobid + ")"
1471+ os .path .join (os .path .basename (logdir ), model , "ckpt-" + check_point )
1472+ if jobid :
1473+ displaystring += " (" + jobid + ")"
14491474 M .waitfor_job = [jobid ]
14501475 V .waitfor_update ()
14511476 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1480,8 +1505,9 @@ async def cluster_actuate():
14801505 M .cluster_cluster_flags ,
14811506 * args )
14821507
1483- displaystring = "CLUSTER " + os .path .basename (V .groundtruth_folder .value .rstrip (os .sep ))+ \
1484- " (" + jobid + ")"
1508+ displaystring = "CLUSTER " + os .path .basename (V .groundtruth_folder .value .rstrip (os .sep ))
1509+ if jobid :
1510+ displaystring += " (" + jobid + ")"
14851511 M .waitfor_job = [jobid ]
14861512 V .waitfor_update ()
14871513 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1543,8 +1569,9 @@ async def delete_ckpts_actuate():
15431569 M .delete_ckpts_ngigabytes_memory ,
15441570 M .delete_ckpts_cluster_flags ,
15451571 * args )
1546- displaystring = "DELETE-CKPTS " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1547- " (" + jobid + ")"
1572+ displaystring = "DELETE-CKPTS " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1573+ if jobid :
1574+ displaystring += " (" + jobid + ")"
15481575 M .waitfor_job = [jobid ]
15491576 V .waitfor_update ()
15501577 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1626,8 +1653,9 @@ async def accuracy_actuate():
16261653 M .accuracy_ngigabytes_memory ,
16271654 M .accuracy_cluster_flags ,
16281655 * args )
1629- displaystring = "ACCURACY " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1630- " (" + jobid + ")"
1656+ displaystring = "ACCURACY " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1657+ if jobid :
1658+ displaystring += " (" + jobid + ")"
16311659 M .waitfor_job = [jobid ]
16321660 V .waitfor_update ()
16331661 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1676,9 +1704,9 @@ async def _freeze_actuate(ckpts):
16761704 "--video_frame_width=" + str (M .video_frame_width ),
16771705 "--video_channels=" + str (M .video_channels ),
16781706 "--igpu=QUEUE1" )
1679- displaystring = "FREEZE " + \
1680- os . path . join ( os . path . basename ( logdir ), model , "ckpt-" + check_point ) + \
1681- " (" + jobid + ")"
1707+ displaystring = "FREEZE " + os . path . join ( os . path . basename ( logdir ), model , "ckpt-" + check_point )
1708+ if jobid :
1709+ displaystring += " (" + jobid + ")"
16821710 M .waitfor_job .append (jobid )
16831711 asyncio .create_task (actuate_monitor (displaystring , None , None , \
16841712 lambda l = logfile , t = currtime : recent_file_exists (l , t , False ), \
@@ -1758,9 +1786,9 @@ async def ensemble_actuate():
17581786 "--video_frame_width=" + str (M .video_frame_width ),
17591787 "--video_channels=" + str (M .video_channels ),
17601788 "--igpu=QUEUE1" )
1761- displaystring = "ENSEMBLE " + \
1762- os . path . join ( os . path . basename ( logdir ), model ) + \
1763- " (" + jobid + ")"
1789+ displaystring = "ENSEMBLE " + os . path . join ( os . path . basename ( logdir ), model )
1790+ if jobid :
1791+ displaystring += " (" + jobid + ")"
17641792 M .waitfor_job .append (jobid )
17651793 asyncio .create_task (actuate_monitor (displaystring , None , None , \
17661794 lambda l = logfile , t = currtime : recent_file_exists (l , t , False ), \
@@ -1822,7 +1850,9 @@ async def _classify_actuate(wavfiles):
18221850 M .classify_ngigabytes_memory ,
18231851 M .classify_cluster_flags ,
18241852 * args )
1825- displaystring = "CLASSIFY " + os .path .basename (wavfile )+ " (" + jobid + ")"
1853+ displaystring = "CLASSIFY " + os .path .basename (wavfile )
1854+ if jobid :
1855+ displaystring += " (" + jobid + ")"
18261856 M .waitfor_job .append (jobid )
18271857 asyncio .create_task (actuate_monitor (displaystring , None , None , \
18281858 lambda l = logfile , t = currtime : recent_file_exists (l , t , False ), \
@@ -1873,7 +1903,9 @@ async def _ethogram_actuate(i, wavfiles, threads, results):
18731903 M .ethogram_cluster_flags ,
18741904 logdir , model , thresholds_file , wavfile ,
18751905 str (M .audio_tic_rate ))
1876- displaystring = "ETHOGRAM " + os .path .basename (wavfile )+ " (" + jobid + ")"
1906+ displaystring = "ETHOGRAM " + os .path .basename (wavfile )
1907+ if jobid :
1908+ displaystring += " (" + jobid + ")"
18771909 M .waitfor_job .append (jobid )
18781910 threads [i ] = asyncio .create_task (actuate_monitor (displaystring , results , i , \
18791911 lambda l = logfile , t = currtime : \
@@ -1917,8 +1949,9 @@ async def compare_actuate():
19171949 M .compare_ngigabytes_memory ,
19181950 M .compare_cluster_flags ,
19191951 * args )
1920- displaystring = "COMPARE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))+ \
1921- " (" + jobid + ")"
1952+ displaystring = "COMPARE " + os .path .basename (V .logs_folder .value .rstrip (os .sep ))
1953+ if jobid :
1954+ displaystring += " (" + jobid + ")"
19221955 M .waitfor_job = jobid
19231956 V .waitfor_update ()
19241957 asyncio .create_task (actuate_monitor (displaystring , None , None , \
@@ -1988,7 +2021,9 @@ async def congruence_actuate():
19882021 "--nprobabilities=" + str (M .nprobabilities ),
19892022 "--audio_tic_rate=" + str (M .audio_tic_rate ),
19902023 "--parallelize=" + str (M .congruence_parallelize ))
1991- displaystring = "CONGRUENCE " + os .path .basename (all_files [0 ])+ " (" + jobid + ")"
2024+ displaystring = "CONGRUENCE " + os .path .basename (all_files [0 ])
2025+ if jobid :
2026+ displaystring += " (" + jobid + ")"
19922027 M .waitfor_job = [jobid ]
19932028 V .waitfor_update ()
19942029 regex_files = '(' + '|' .join ([os .path .splitext (x )[0 ] for x in all_files ])+ ')*csv'
0 commit comments