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

Source Code for Module Ganga.Core.JobRepository.Base

  1  ################################################################################ 
  2  # Ganga Project. http://cern.ch/ganga 
  3  # 
  4  # $Id: Base.py,v 1.1 2008-07-17 16:40:50 moscicki Exp $ 
  5  ################################################################################ 
  6   
7 -class JobRepository(object):
8 """JobRepository class is an interface for developers, that need to access 9 jobs/job attributes stored in the database. 10 Implementation details are given in the derived class. 11 """ 12
13 - def __init__(self, schema, role, streamer = None, tree_streamer = None):
14 """schema is a subset of job schema. It should be list of tuples 15 (attr, dbtype), where attr is a name of attribute, and dbtype is 16 database specific type. 17 role can be 'Client' or 'JobManager'. 'Client' can only modify job 18 status of 'new' jobs 19 streamer is an object which converts job dictionary into a string and 20 vice versa. 21 tree_streamer is an object which converts jobtree into a string and 22 vice versa. 23 """ 24 self.schema = schema 25 assert(role in ['Client', 'JobManager']) 26 self._role = role 27 self._streamer = streamer 28 self._tree_streamer = tree_streamer 29 from Ganga.Utility.guid import newGuid 30 self.guid = newGuid(self)
31 32
33 - def _getStreamFromJob(self, job):
34 if self._streamer: 35 return self._streamer.getStreamFromJob(job) 36 return ''
37
38 - def _getJobFromStream(self, stream):
39 if self._streamer: 40 return self._streamer.getJobFromStream(stream) 41 return
42
43 - def registerJobs(self, jobs):
44 """registerJobs(self, jobs) --> None 45 throws RepositoryError 46 jobs -- list of jobs to register 47 """ 48 return
49
50 - def commitJobs(self, jobs):
51 """commitJobs(self, jobs) --> None 52 throws RepositoryError 53 jobs -- list of jobs to commit 54 jobs must already be registered 55 """ 56 return
57
58 - def checkoutJobs(self, ids_or_attributes):
59 """checkoutJobs(self, ids_or_attributes) --> list of jobs 60 throws RepositoryError 61 ids_or_attributes -- list of job ids 62 or dictionary of job attributes saved 63 in the DB as metadata. Example of attributes: 64 attributes = {'status':'submitted', 'application':'DaVinci'} 65 """ 66 return []
67
68 - def deleteJobs(self, ids):
69 """deleteJob(self, ids) --> None 70 throws RepositoryError 71 ids -- list of job ids 72 """ 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 return []
85
86 - def getJobAttributes(self, ids_or_attributes):
87 """getJobAttributes(self, ids_or_attributes) --> list of dictionaries with 88 job metadata stored in the registry. 89 throws RepositoryError 90 ids_or_attributes -- list of job ids 91 or dictionary of job attributes saved 92 in the DB as metadata. Example of attributes: 93 attributes = {'status':'submitted', 'application':'DaVinci'} 94 """ 95 return []
96
97 - def setJobsStatus(self, statusList):
98 """setJobsStatus(self, statusList) --> None 99 throws RepositoryError 100 statusList -- list of tuples (<jobId>, <status>) 101 Supposed to be used by JobManager 102 """ 103 return
104
105 - def getJobsStatus(self, ids_or_attributes):
106 """getJobsStatus(self, ids_or_attributes) --> list of tuples, indicating 107 jobid and job status: (id, status). 108 throws RepositoryError 109 ids_or_attributes -- list of job ids 110 or dictionary of job attributes saved 111 in the DB as metadata. Example of attributes: 112 attributes = {'application':'DaVinci'} 113 """ 114 return []
115
116 - def getJobTree(self, tree_id = 0):
117 """getJobTree(self, tree_id = 0) --> jobtree object. 118 throws RepositoryError. 119 tree_id - id of jobtree in registry. Can be used to support back up""" 120 return
121
122 - def setJobTree(self, jobtree, tree_id = 0):
123 """setJobTree(self, jobtree, tree_id = 0) --> None. 124 throws RepositoryError. 125 Registers and/or modifies jobtree object in the repository. 126 jobtree - jobtree object 127 tree_id - id of jobtree in registry. Can be used to support back up""" 128 return
129