ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/DBinterface.py
(Generate patch)

Comparing COMP/CRAB/python/DBinterface.py (file contents):
Revision 1.2 by spiga, Tue Mar 4 15:50:44 2008 UTC vs.
Revision 1.6 by slacapra, Fri Mar 7 17:25:23 2008 UTC

# Line 40 | Line 40 | class DBinterface:
40          common.bossSession = BossLiteAPI( self.db_type, dbConfig)
41          
42          return
43 +
44 +    def getTask(self):
45 +
46 +        self.task = common.bossSession.loadTaskByID(1)
47 +        return self.task
48  
49 +    def getJob(self, n):
50 +
51 +        self.job = common.bossSession.loadJobByID(1,n)
52 +        return self.job
53  
54  
55      def createTask_(self, optsToSave):      
56          """
57          Task declaration
58          with the first coniguration stuff
59 <         {'server_name': 'crabas.lnl.infn.it/data1/cms/', '-scheduler': 'glite', '-jobtype': 'cmssw', '-server_mode': '0'}
59 >        {'server_name': 'crabas.lnl.infn.it/data1/cms/', '-scheduler': 'glite', '-jobtype': 'cmssw', '-server_mode': '0'}
60  
61          """
62          opt={}
63 <        if optsToSave['server_mode'] == 1: opt['serverName']=optsToSave['server_name']
63 >        opt['serverName']=optsToSave.get('server_name',0)
64          opt['jobType']=optsToSave['jobtype']  
65          opt[ 'name']=common.work_space.taskName()  
66          task = Task( opt )
# Line 81 | Line 90 | class DBinterface:
90          jobs = []
91          for id in range(nj):
92              parameters = {}
93 <            parameters['name'] = 'job' + str(id)
93 >            parameters['name'] = id
94              job = Job(parameters)
95              jobs.append(job)    
96          task.addJobs(jobs)
# Line 106 | Line 115 | class DBinterface:
115          """
116          task = common.bossSession.loadTaskByID(1)
117          #task = common.bossSession.loadTaskByName( common.work_space.taskName())
118 <        common.bossSession.getRunningInstance(task.jobs[nj])
118 >        common.bossSession.getRunningInstance(task.jobs[nj-1])
119          for key in optsToSave.keys():
120 <            task.jobs[nj].runningJob[key] = optsToSave[key]
120 >            task.jobs[nj-1].runningJob[key] = optsToSave[key]
121          common.bossSession.updateDB( task )
122          return
123  
# Line 193 | Line 202 | class DBinterface:
202          task = common.bossSession.loadTaskByID(1)
203         # task = common.bossSession.loadTaskByName( common.work_space.taskName() )
204          for i in jobs:
205 <            common.bossSession.getRunningInstance(task.jobs[i])
206 <            lines.append(task.jobs[i].runningJob[attr])
205 >            common.bossSession.getRunningInstance(task.jobs[i-1])
206 >            lines.append(task.jobs[i-1].runningJob[attr])
207          return lines
208 +
209 +    def queryDistJob(self, attr):
210 +        '''
211 +        Returns the list of distinct value for a given job attributes
212 +        '''
213 +        distAttr=[]
214 +        task = common.bossSession.loadJobDist( 1, attr )
215 +        for i in task: distAttr.append(i[attr])  
216 +        return  distAttr
217 +
218 +    def queryDistJob_Attr(self, attr_1, attr_2, list):
219 +        '''
220 +        Returns the list of distinct value for a given job attributes
221 +        '''
222 +        distAttr=[]
223 +        task = common.bossSession.loadJobDistAttr( 1, attr_1, attr_2, list )
224 +        for i in task: distAttr.append(i[attr_1])  
225 +        return  distAttr
226 +
227 +    def queryAttrJob(self, attr, field):
228 +        '''
229 +        Returns the list of jobs matching the given attribute
230 +        '''
231 +        matched=[]
232 +        task = common.bossSession.loadJobsByAttr(attr )
233 +        for i in task:
234 +            matched.append(i[field])
235 +        return  matched
236 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines