+ renamed dyn_prog directory
[qpalma.git] / scripts / ModelSelection.py
1 #!/usr/bin/env python
2 # -*- coding:latin-1 -*-
3
4 import cPickle
5 import os
6 import os.path
7 import time
8 import pdb
9 import subprocess
10
11 from qpalma_main import QPalma
12 import Experiment as Exp
13
14 class Model:
15
16 allInstances = []
17
18 def __init__(self):
19 pass
20
21 def createInstances(self):
22
23 allRuns = Exp.createRuns()
24
25 #pdb.set_trace()
26
27 for currentRun in allRuns:
28
29 currentInstance = QPalma(currentRun)
30
31 #print 'instance created, starting to pickle configuration...'
32 name = currentRun['name']
33 instance_fn = '%s.pickle'%name
34 fh = open(instance_fn,'w+')
35 cPickle.dump(currentInstance,fh)
36 fh.close()
37
38 self.allInstances.append(instance_fn)
39
40
41 def doSelection(self):
42 for instance in self.allInstances:
43 time.sleep(2)
44 cmd = 'echo ./resurrect %s | qsub -l h_vmem=5.0G -cwd -j y -N \"%s.log\"'%(instance,instance)
45 #print cmd
46 os.system(cmd)
47
48 #os.system('echo "./resurrect %s >out_%s.log 2>err_%s.log &"'%(instance,instance,instance))
49
50
51 def doPrediction(self):
52 current_dir = '/fml/ag-raetsch/home/fabio/tmp/QPalma_single_run'
53
54 for instance in self.allInstances:
55 time.sleep(2)
56 cmd = '/fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/doPrediction.sh %s 1>_%s.log 2>%s.log & '%(instance,instance,instance)
57 #cmd = 'echo /fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/doPrediction.sh %s |\
58 #qsub -l h_vmem=12.0G -cwd -j y -N \"%s.log\"'%(instance,instance)
59 #os.system(cmd)
60 obj = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
61 #out,err = obj.communicate()
62 #print out,err
63
64
65
66 if __name__ == '__main__':
67 m = Model()
68 m.createInstances()
69 m.doSelection()
70 #m.doPrediction()
71