|
def | __init__ (self, fileName, forceNew=False, dbName='IDBSDQ', tag='nominal', user='sys:dqBeamSpot') |
|
def | __del__ (self) |
|
def | connect (self, fileName, forceNew=False, dbName='IDBSDQ', tag='nominal') |
|
def | defectType (self, t) |
|
def | add (self, runMin=0, runMax=(1<< 31) -1, lbMin=0, lbMax=(1<< 32) -1) |
|
def | complete (self, runMin, runMax) |
|
def | writeDefects (self, tag='nominal', nonpresent=False) |
|
def | dump (self, filename=None) |
|
Class for writing BS defects to an sqlite file
Definition at line 19 of file DQUtilities.py.
◆ __init__()
def python.DQUtilities.IDBSDefectWriter.__init__ |
( |
|
self, |
|
|
|
fileName, |
|
|
|
forceNew = False , |
|
|
|
dbName = 'IDBSDQ' , |
|
|
|
tag = 'nominal' , |
|
|
|
user = 'sys:dqBeamSpot' |
|
) |
| |
Initialise database connection
Definition at line 24 of file DQUtilities.py.
24 def __init__(self,fileName, forceNew=False, dbName='IDBSDQ', tag='nominal', user='sys:dqBeamSpot
'): """
25 Initialise database connection
33 if not fileName: fileName =
'tmp.'+
str(os.getpid())+
'.db'
35 self.connect(fileName, forceNew, dbName, tag)
◆ __del__()
def python.DQUtilities.IDBSDefectWriter.__del__ |
( |
|
self | ) |
|
Delete db to clear connection
Definition at line 40 of file DQUtilities.py.
42 Delete db to clear connection
45 os.system(
'[[ -f tmp.%s.db ]] && rm tmp.%s.db' %(os.getpid(), os.getpid()))
◆ _writeDefect()
def python.DQUtilities.IDBSDefectWriter._writeDefect |
( |
|
self, |
|
|
|
defect, |
|
|
|
since, |
|
|
|
until, |
|
|
|
tag = 'nominal' , |
|
|
|
description = '' , |
|
|
|
comment = '' , |
|
|
|
present = True , |
|
|
|
recoverable = False |
|
) |
| |
|
private |
Write a single defect to the database
Definition at line 158 of file DQUtilities.py.
158 def _writeDefect(self,defect, since, until, tag='nominal', description='', comment='', present=True, recoverable=False):
160 Write a single defect to the database
163 if defect
not in self.db.defect_names:
164 self.db.create_defect(defect, description)
166 self.db.insert(defect, since, until, comment, self.user, present, recoverable)
◆ add()
def python.DQUtilities.IDBSDefectWriter.add |
( |
|
self, |
|
|
|
runMin = 0 , |
|
|
|
runMax = (1 << 31)-1 , |
|
|
|
lbMin = 0 , |
|
|
|
lbMax = (1 << 32)-1 |
|
) |
| |
Add iovs which are NOT defective to the list
Note, lbMax is exclusive here (and inclusive when shown on defect web page).
Definition at line 72 of file DQUtilities.py.
72 def add(self,runMin=0, runMax=(1 << 31)-1, lbMin=0, lbMax=(1 << 32)-1):
74 Add iovs which are NOT defective to the list
75 Note, lbMax is exclusive here (and inclusive when shown on defect web page).
79 since = RunLumiType((runMin << 32)+lbMin)
80 until = RunLumiType((runMax << 32)+lbMax)
83 self.iovs.
add(since, until, self.defect,
False)
◆ complete()
def python.DQUtilities.IDBSDefectWriter.complete |
( |
|
self, |
|
|
|
runMin, |
|
|
|
runMax |
|
) |
| |
Complete a list of IoVs to cover all LBs in a run, treating empty ones as having 'emptyState'
Definition at line 87 of file DQUtilities.py.
87 def complete(self, runMin, runMax):
89 Complete a list of IoVs to cover all LBs in a run, treating empty ones as having 'emptyState'
94 run_lbs =
fetch_iovs(
"EOR", runs=(runMin, runMax), what=[], with_channel=
False)
105 print (
"WARNING: No LBs in run according to EOR_Params - are we running before the run has finished?")
107 def lbsStartAtOne(iov):
108 "Change LBs starting at 0 to start at 1"
109 return iov._replace(since=
RunLumi(iov.since.run, 1))
112 run_lbs = [lbsStartAtOne(iov)
for iov
in run_lbs
if iov.until.lumi > 1]
118 defectsCurrentlyInDb = self.officialDb.
retrieve((runMin, 0), (runMax+1, 0), [self.defect])
121 self.iovs = IOVSet(
sorted(self.iovs))
124 for since, until, (run_lb, iov, dbDefect)
in process_iovs(run_lbs, self.iovs.solidify(DEFECTIOV_VAL), defectsCurrentlyInDb):
125 if not run_lb:
continue
136 if dbDefect
and dbDefect.present:
139 iovs.add(since, until, self.defect,
False)
142 iovs.add(since, until, self.defect,
True)
◆ connect()
def python.DQUtilities.IDBSDefectWriter.connect |
( |
|
self, |
|
|
|
fileName, |
|
|
|
forceNew = False , |
|
|
|
dbName = 'IDBSDQ' , |
|
|
|
tag = 'nominal' |
|
) |
| |
Open connection to defect DB
Definition at line 50 of file DQUtilities.py.
50 def connect(self, fileName, forceNew=False, dbName='IDBSDQ', tag='nominal'):
52 Open connection to defect DB
55 connString =
'sqlite://;schema=%s;dbname=%s' % (fileName,dbName)
57 if forceNew
and os.path.exists(fileName):
60 self.db = DefectsDB(connString, read_only=
False, create=
True, tag=(tag,
'HEAD'))
62 self.officialDb = DefectsDB()
◆ defectType()
def python.DQUtilities.IDBSDefectWriter.defectType |
( |
|
self, |
|
|
|
t |
|
) |
| |
Set defect type
Definition at line 66 of file DQUtilities.py.
66 def defectType(self,t):
◆ dump()
def python.DQUtilities.IDBSDefectWriter.dump |
( |
|
self, |
|
|
|
filename = None |
|
) |
| |
Dump defects to a file given by filename or stdout if no filename given
Definition at line 170 of file DQUtilities.py.
170 def dump(self, filename = None):
172 Dump defects to a file given by filename or stdout if no filename given
175 from DQUtils.utils
import pprint_objects
177 if filename
is not None:
178 f =
open(filename.replace(
'.db',
'.txt'),
"w")
187 print (
'\nNo DQ defects')
◆ writeDefects()
def python.DQUtilities.IDBSDefectWriter.writeDefects |
( |
|
self, |
|
|
|
tag = 'nominal' , |
|
|
|
nonpresent = False |
|
) |
| |
Write all defects to the database. If 'nonpresent' is True then write the absent ones too
Definition at line 147 of file DQUtilities.py.
147 def writeDefects(self, tag='nominal', nonpresent=False):
149 Write all defects to the database. If 'nonpresent' is True then write the absent ones too
152 with self.db.storage_buffer:
153 for since, until, defect, present
in self.iovs:
154 if not present
and not nonpresent:
continue
156 self._writeDefect(defect, since, until, present = present)
◆ db
python.DQUtilities.IDBSDefectWriter.db |
◆ defect
python.DQUtilities.IDBSDefectWriter.defect |
◆ iovs
python.DQUtilities.IDBSDefectWriter.iovs |
◆ officialDb
python.DQUtilities.IDBSDefectWriter.officialDb |
◆ user
python.DQUtilities.IDBSDefectWriter.user |
The documentation for this class was generated from the following file:
def fetch_iovs(folder_name, since=None, until=None, channels=None, tag="", what="all", max_records=-1, with_channel=True, loud=False, database=None, convert_time=False, named_channels=False, selection=None, runs=None, with_time=False, unicode_strings=False)