yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #05672
[Branch ~yade-dev/yade/trunk] Rev 2436: 1. Avoid adding useless lines of nans in plot for unknown variables, add only their column instead
------------------------------------------------------------
revno: 2436
committer: Chiara Modenese <chia@engs-018373>
branch nick: trunk
timestamp: Mon 2010-09-13 12:32:30 +0100
message:
1. Avoid adding useless lines of nans in plot for unknown variables, add only their column instead
2. Save job figure as soon as the job finishes in the batch
3. Fi O.tags['id.d'] and O.tags['d.id'] tag order
modified:
core/main/yade-batch.in
py/plot.py
py/utils.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/main/yade-batch.in'
--- core/main/yade-batch.in 2010-09-10 11:33:21 +0000
+++ core/main/yade-batch.in 2010-09-13 11:32:30 +0000
@@ -1,7 +1,7 @@
#!${pyExecutable}
#Â encoding: utf-8
+#
# vim: syntax=python
-#
# portions © 2008 Václav Šmilauer <eudoxos@xxxxxxxx>
import os, sys, thread, time, logging, pipes, socket, xmlrpclib, re, shutil
@@ -130,7 +130,7 @@
plotMatch=re.match('/jobs/([0-9]+)/plots',self.path)
if plotMatch:
jobId=int(plotMatch.group(1));
- if jobId>=len(jobs): self.send_error(404)
+ if jobId>=len(jobs) or not os.path.exists(jobs[jobId].plotsFile): self.send_error(404)
jobs[jobId].updatePlots() # internally checks for last update time
self.sendFile(jobs[jobId].plotsFile,contentType=yade.remote.plotImgMimetype,refresh=5)
return
@@ -152,7 +152,7 @@
return
def log_request(self,req): pass
def sendGlobal(self):
- html='<HTML><TITLE>Yade-multi at %s overview</TITLE><BODY>\n'%(socket.gethostname())
+ html='<HTML><TITLE>Yade-batch at %s overview</TITLE><BODY>\n'%(socket.gethostname())
html+=globalHtmlStats()
html+='<TABLE border=1><tr><th>id</th><th>status</th><th>info</th><th>slots</th><th>plots</th><th>command</th></tr>\n'
for j in jobs: html+=j.htmlStats()+'\n'
@@ -194,7 +194,13 @@
job.duration=t2hhmmss(dt)
strStatus='done ' if job.exitStatus==0 else 'FAILED '
job.status='DONE'
- print "#%d (%s%s) %s (exit status %d), duration %s, log %s"%(job.num,job.id,'' if job.nSlots==1 else '/%d'%job.nSlots,strStatus,job.exitStatus,job.duration,job.log)
+ havePlot=False
+ if os.path.exists(job.plotsFile):
+ f=(job.log[:-3] if job.log.endswith('.log') else job.log+'.')+yade.remote.plotImgFormat
+ shutil.copy(job.plotsFile,f)
+ job.plotsFile=f
+ havePlot=True
+ print "#%d (%s%s) %s (exit status %d), duration %s, log %s%s"%(job.num,job.id,'' if job.nSlots==1 else '/%d'%job.nSlots,strStatus,job.exitStatus,job.duration,job.log,(', plot %s'%(job.plotsFile) if havePlot else ''))
job.saveInfo()
def runJobs(jobs,numSlots):
@@ -229,7 +235,7 @@
parser.add_option('--job-threads',dest='defaultThreads',type='int',help="Default number of threads for one job; can be overridden by per-job OMP_NUM_THREADS. Defaults to allocate all available cores (%d) for each job."%numCores,metavar='NUM',default=numCores)
parser.add_option('--force-threads',action='store_true',dest='forceThreads')
parser.add_option('--log',dest='logFormat',help='Format of job log files -- must contain a % or @, which will be replaced by line number or by description column respectively (default: SIMULATION.@.log)',metavar='FORMAT')
-parser.add_option('--global-log',dest='globalLog',help='Filename where to redirect output of yade-multi itself (as opposed to --log); if not specified (default), stdout/stderr are used',metavar='FILE')
+parser.add_option('--global-log',dest='globalLog',help='Filename where to redirect output of yade-batch itself (as opposed to --log); if not specified (default), stdout/stderr are used',metavar='FILE')
parser.add_option('-l','--lines',dest='lineList',help='Lines of TABLE to use, in the format 2,3-5,8,11-13 (default: all available lines in TABLE)',metavar='LIST')
parser.add_option('--nice',dest='nice',type='int',help='Nice value of spawned jobs (default: 10)',default=10)
parser.add_option('--executable',dest='executable',help='Name of the program to run (default: %s)'%executable,default=executable,metavar='FILE')
@@ -329,9 +335,7 @@
plots=[]
for j in jobs:
if not os.path.exists(j.plotsFile): continue
- f=(j.log[:-3] if j.log.endswith('.log') else j.log+'.')+yade.remote.plotImgFormat
- shutil.copy(j.plotsFile,f)
- plots.append(f)
+ plots.append(j.plotsFile)
if plots: print 'Plot files:',' '.join(plots)
# for easy grepping in logfiles:
=== modified file 'py/plot.py'
--- py/plot.py 2010-09-10 11:33:21 +0000
+++ py/plot.py 2010-09-13 11:32:30 +0000
@@ -81,6 +81,13 @@
"""
for k in data: data[k].reverse()
+def addDataColumns(dd):
+ '''Add new columns with NaN data, without adding anything to other columns. Does nothing for columns that already exist'''
+ numSamples=len(data[data.keys()[0]]) if len(data)>0 else 0
+ for d in dd:
+ if d in data.keys(): continue
+ d[d]=[nan for i in range(numSamples)]
+
def addData(*d_in,**kw):
"""Add data from arguments name1=value1,name2=value2 to yade.plot.data.
(the old {'name1':value1,'name2':value2} is deprecated, but still supported)
@@ -156,7 +163,9 @@
if d[0] not in data.keys(): missing.add(d[0])
if len(data.keys())==0 or len(data[data.keys()[0]])==0: # no data at all yet, do not add garbage NaNs
for m in missing: data[m]=[]
- else: addData(dict((m,nan) for m in missing))
+ else:
+ print 'Missing columns in plot.data, adding NaN: ',','.join(list(missing))
+ addDataColumns(missing)
# create y1 lines
for d in plots_p_y1:
line,=pylab.plot(data[pStrip],data[d[0]],d[1])
=== modified file 'py/utils.py'
--- py/utils.py 2010-09-10 11:33:21 +0000
+++ py/utils.py 2010-09-13 11:32:30 +0000
@@ -788,7 +788,7 @@
vv=allTab[tableLine]
O.tags['line']='l%d'%tableLine
O.tags['description']=vv['description']
- O.tags['d.id']=O.tags['id']+'.'+O.tags['description']; O.tags['id.d']=O.tags['description']+'.'+O.tags['id']
+ O.tags['id.d']=O.tags['id']+'.'+O.tags['description']; O.tags['d.id']=O.tags['description']+'.'+O.tags['id']
# assign values specified in the table to python vars
# !something cols are skipped, those are env vars we don't treat at all (they are contained in description, though)
for col in vv.keys():