Package Ganga :: Package Core :: Package JobRepository :: Module TestRepository
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Core.JobRepository.TestRepository

  1  from Ganga.Utility.logging import getLogger 
  2   
  3  logger = getLogger(modulename=1) 
  4   
  5  from Base import JobRepository 
  6   
7 -class JobInfo:
8 - def __init__(self,job,**kwds):
9 self.j = job 10 self.commit = 0 11 self.checkout = 0 12 self.register = 0 13 14 for k in kwds: 15 setattr(self,k,kwds[k])
16
17 -class TestRepository(JobRepository):
18 - def __init__(self,schema,role,streamer,root_dir,**kwds):
19 print '*'*100 20 logger.debug('__init__ %s',str((schema,role,streamer,root_dir))) 21 JobRepository.__init__(self,schema,role,streamer) 22 self.root = root_dir 23 self.id_counter = 0 24 self.jobs = {} 25 self.trash = {}
26
27 - def registerJobs(self,jobs):
28 #file(self.root) 29 for j in jobs: 30 self.id_counter += 1 31 j.id = self.id_counter 32 self.jobs[j.id] = JobInfo(j,register=1) 33 logger.debug('registerJobs %s',str([j.id for j in jobs]))
34
35 - def commitJobs(self, jobs):
36 """commitJobs(self, jobs) --> None 37 throws RepositoryError 38 jobs -- list of jobs to commit 39 jobs must already be registered 40 """ 41 logger.debug('commitJobs %s',str([j.id for j in jobs])) 42 43 for j in jobs: 44 if not self.jobs.has_key(j.id): 45 raise ValueError('attempt to commit job is not registered',j.id) 46 47 self.jobs[j.id].commit += 1 48 logger.debug("commited job %d (%d)",j.id,self.jobs[j.id].commit)
49
50 - def checkoutJobs(self, ids_or_attributes):
51 """checkoutJobs(self, ids_or_attributes) --> list of jobs 52 throws RepositoryError 53 ids_or_attributes -- list of job ids 54 or dictionary of job attributes saved 55 in the DB as metadata. Example of attributes: 56 attributes = {'status':'submitted', 'application':'DaVinci'} 57 """ 58 logger.debug('checkoutJobs %s',str(ids_or_attributes)) 59 return []
60
61 - def deleteJobs(self, ids):
62 """deleteJob(self, ids) --> None 63 throws RepositoryError 64 ids -- list of job ids 65 """ 66 logger.debug('deleteJobs %s',str(ids)) 67 for id in ids: 68 if not self.jobs.has_key(id): 69 raise ValueError('attempt to delet job which does not exist %d',id) 70 self.trash[id] = self.jobs[id] 71 del self.jobs[id] 72 logger.debug('deleted job %d',id) 73 return
74
75 - def getJobIds(self, ids_or_attributes):
76 """getJobIds(self, ids_or_attributes) --> list of ids for the jobs having 77 specified attributes. 78 throws RepositoryError 79 ids_or_attributes -- list of job ids 80 or dictionary of job attributes saved 81 in the DB as metadata. Example of attributes: 82 attributes = {'status':'submitted', 'application':'DaVinci'} 83 """ 84 logger.debug('getJobIds %s',str(ids_or_attributes)) 85 return []
86
87 - def getJobAttributes(self, ids_or_attributes):
88 """getJobAttributes(self, ids_or_attributes) --> list of dictionaries with 89 job metadata stored in the registry. 90 throws RepositoryError 91 ids_or_attributes -- list of job ids 92 or dictionary of job attributes saved 93 in the DB as metadata. Example of attributes: 94 attributes = {'status':'submitted', 'application':'DaVinci'} 95 """ 96 logger.debug('getJobAttributes %s',str(ids_or_attributes)) 97 return []
98
99 - def setJobsStatus(self, statusList):
100 """setJobsStatus(self, statusList) --> None 101 throws RepositoryError 102 statusList -- list of tuples (<jobId>, <status>) 103 Supposed to be used by JobManager 104 """ 105 logger.debug('setJobsStatus %s',str(statusList)) 106 return
107
108 - def getJobsStatus(self, ids_or_attributes):
109 """getJobsStatus(self, ids_or_attributes) --> list of tuples, indicating 110 jobid and job status: (id, status). 111 throws RepositoryError 112 ids_or_attributes -- list of job ids 113 or dictionary of job attributes saved 114 in the DB as metadata. Example of attributes: 115 attributes = {'application':'DaVinci'} 116 """ 117 logger.debug('getJobStatus %s',str(ids_or_attributes)) 118 return []
119