← Back to team overview

yade-dev team mailing list archive

[svn] r1621 - trunk/gui/py

 

Author: eudoxos
Date: 2009-01-10 11:42:40 +0100 (Sat, 10 Jan 2009)
New Revision: 1621

Modified:
   trunk/gui/py/yade-multi
Log:
Exit once the simulation finishes; do not rely on simulation exiting itself.


Modified: trunk/gui/py/yade-multi
===================================================================
--- trunk/gui/py/yade-multi	2009-01-10 08:11:53 UTC (rev 1620)
+++ trunk/gui/py/yade-multi	2009-01-10 10:42:40 UTC (rev 1621)
@@ -87,7 +87,7 @@
 
 parser=optparse.OptionParser(usage='%prog [options] TABLE SIMULATION.py\n\n  %prog runs yade simulation multiple times with different parameters.\n  See http://yade.wikia.com/wiki/ScriptParametricStudy for details.')
 parser.add_option('-j',dest='maxJobs',type='int',help="Maximum number of simultaneous jobs to run (default: number of cores, i.e. %d)"%getNumCores(),metavar='NUM',default=getNumCores())
-parser.add_option('--log',dest='logFormat',help='Format of log files -- must contain a %, which will be replaced by line number (default: SIMULATION.%.log)',metavar='FORMAT')
+parser.add_option('--log',dest='logFormat',help='Format of 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('-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)'%sys.argv[0][:-6],default=sys.argv[0][:-6],metavar='FILE') ## strip the '-multi' extension
@@ -100,7 +100,7 @@
 	sys.exit(1)
 table,simul=args[0:2]
 if not logFormat: logFormat=(simul[:-3] if simul[-3:]=='.py' else simul)+".%.log"
-if not '%' in logFormat: raise StandardError("Log string must contain a `%'")
+if (not '%' in logFormat) and ('@' not in logFormat): raise StandardError("Log string must contain at least one of `%', `@'")
 
 print "Will run `%s' on `%s' with nice value %d, output redirected to `%s', %d jobs at a time."%(executable,simul,nice,logFormat,maxJobs)
 
@@ -124,12 +124,22 @@
 		else: useLines+=[l]
 else: useLines=availableLines
 print "Will use lines ",', '.join([str(i) for i in useLines])+'.'
+# find column where description is
+try:
+	idColumn=ll[0].split().index('description')
+	idStrings={}
+	for i in useLines: idStrings[i]=ll[i].split()[idColumn] # textual descripion of respective lines 
+	print idStrings
+except IndexError:
+	idColumn=None
+	idStrings=None
 
 
 batches=[]
 for l in useLines:
 	logFile=logFormat.replace('%',str(l))
-	batches.append('PARAM_TABLE=%s:%d nice -n %d %s -N PythonUI -- -n %s > %s 2>&1'%(table,l,nice,executable,simul,logFile))
+	if idStrings: logFile=logFile.replace('@',idStrings[l])
+	batches.append('PARAM_TABLE=%s:%d nice -n %d %s -N PythonUI -- -n -x %s > %s 2>&1'%(table,l,nice,executable,simul,logFile))
 print "Job summary:"
 for i in range(len(batches)):
 	print '   #%d:'%i, batches[i]