4 import matplotlib.pyplot
as plt
7 from datetime
import datetime,time,timedelta
8 from winnet_class
import winnet
19 use_slurm_times =
False
28 cmd =
"squeue | grep "+user+
" | grep R | wc -l"
29 x = subprocess.check_output(cmd, shell=
True)
30 nr_process = int(x.strip())
39 all_folders = os.listdir(path)
41 tot_path = os.path.join(path,p)
42 if not os.path.isdir(tot_path):
45 w_path = os.path.join(tot_path,
"winnet")
46 b_path = os.path.join(tot_path,
"blocked")
47 f_path = os.path.join(tot_path,
"finab.dat")
48 h_path = os.path.join(tot_path,
"WinNet_data.h5")
49 o_path = os.path.join(tot_path,
"OUT")
51 if not os.path.isfile(w_path)
and not os.path.isfile(b_path):
53 elif not os.path.isfile(w_path)
and os.path.isfile(b_path):
55 if os.path.isfile(f_path):
57 if not use_slurm_times:
60 eltime.append(w.elapsed_time)
62 elif os.path.isfile(h_path):
63 ftmp = h5py.File(h_path,
"r")
65 if not use_slurm_times:
68 eltime.append(w.elapsed_time)
74 elif os.path.isfile(w_path)
and os.path.isfile(b_path):
81 cmd =
"squeue | grep "+user+
" | grep R | awk '{print $6}' "
82 x = subprocess.check_output(cmd, shell=
True)
91 tottime = float(days[0])*24
96 days = days.split(
":")
99 tottime += float(days[0])/60.+float(days[1])/60./60.
101 tottime += float(days[0])+float(days[1])/60.+float(days[2])/60./60.
105 av_time = np.average(ttt)
107 ttt = np.array(eltime)/60./60.
110 av_per_h = 1./(np.nanmean(eltime)/60./60./allRem)
111 av_time = allFin/av_per_h
113 av_per_h = 1./allFin/(np.nanmean(eltime)/60./60./nr_process)
114 av_time = allFin/av_per_h
116 av_per_h = 1./allFin/(np.nanmean(eltime)/60./60./100.)
117 av_time = allFin/av_per_h
120 if allFin != 0
and len(ttt)>0:
122 elif allFin+allFail == allTotal:
127 av_per_h = 1./((1.5/6.)/allRem)
129 av_per_h = 1./((1.5/6.)/nr_process)
131 av_per_h = 1./((1.5/6.)/100)
136 rest_runs = allTotal-allFin-allFail
138 est_time = rest_runs/av_per_h
140 est_time = np.round(est_time*60*60)
141 secs = int(est_time % 60)
142 est_time = (est_time-secs)/60.
143 mins = int(est_time % 60)
144 est_time = int((est_time-mins)/60.)
151 timestr = str(hours).zfill(2)+
":"+str(mins).zfill(2)+
":"+str(secs).zfill(2)
154 date_object = timedelta(hours=hours,minutes=mins,seconds=secs)
159 finishtime = now+date_object
162 est_time = np.round(av_time*60*60)
163 secs2 = int(est_time % 60)
164 est_time = (est_time-secs)/60.
165 mins2 = int(est_time % 60)
166 est_time = int((est_time-mins)/60.)
168 timestr2 = str(hours2).zfill(2)+
":"+str(mins2).zfill(2)+
":"+str(secs2).zfill(2)
174 outstr +=
" WinNet monitoring "+
"\n"
175 outstr +=
"===================================="+
"\n"
177 outstr +=
"| Number of runs | "+str(allTotal).rjust(10)+
" | \n"
178 outstr +=
"| Running | "+str(allRem).rjust(10) +
" | \n"
179 outstr +=
"| Finished | "+str(allFin).rjust(10) +
" | \n"
180 outstr +=
"| Failed | "+str(allFail).rjust(10) +
" | \n"
181 outstr +=
"| --------------------------------"+
" | \n"
183 outstr +=
"| Av. time / tracer | "+timestr2.rjust(10) +
" | \n"
184 outstr +=
"| Estimated duration | "+timestr.rjust(10) +
" | \n"
185 outstr +=
"| Estimated finish | "+finishtime.strftime(
"%H:%M:%S").rjust(10) +
" | \n"
186 outstr +=
"|"+
"_"*34 +
"| \n"