CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
dqm_interfaces.DQMcommunicator Class Reference
Inheritance diagram for dqm_interfaces.DQMcommunicator:

Public Member Functions

def __init__ (self, server, is_private=False, ident="DQMToJson/1.0 python/%d.%d.%d"%version_info[:3])
 
def cd (self, args)
 
def get_common_runs (self, dataset_string1, dataset_string2)
 
def get_data (self, full_url)
 
def get_dataset_runs (self, dataset_string)
 
def get_datasets_list (self, dataset_string="")
 
def get_RelVal_CMSSW_versions (self, query)
 
def get_root_objects (self, url="")
 
def get_root_objects_list (self, url="")
 
def get_root_objects_list_recursive (self, url="")
 
def get_root_objects_names_list_recursive (self, url="", present_url="")
 
def get_root_objects_recursive (self, url="", present_url="")
 
def get_runs_list (self, dataset_string)
 
def get_samples (self, samples_string="*")
 
def ls (self, url='', fetch_root=False)
 
def ls_url (self, url)
 
def open_url (self, url)
 

Public Attributes

 DQMpwd
 
 ident
 
 is_private
 
 oldDQMpwd
 
 opener
 
 prevDQMpwd
 
 server
 

Static Public Attributes

 base_dir
 

Detailed Description

Communicate with the DQM Document server

Definition at line 52 of file dqm_interfaces.py.

Constructor & Destructor Documentation

def dqm_interfaces.DQMcommunicator.__init__ (   self,
  server,
  is_private = False,
  ident = "DQMToJson/1.0 python/%d.%d.%d" % version_info[:3] 
)

Definition at line 63 of file dqm_interfaces.py.

63  ident="DQMToJson/1.0 python/%d.%d.%d" % version_info[:3]):
64  self.ident = ident
65  self.server = server
66  self.is_private = is_private
67  self.DQMpwd=DQMcommunicator.base_dir
68  self.prevDQMpwd=self.DQMpwd
69  self.opener=None
70  if not self.is_private:
71  self.opener=build_opener(X509CertOpen())

Member Function Documentation

def dqm_interfaces.DQMcommunicator.cd (   self,
  args 
)

Definition at line 156 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.oldDQMpwd, and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DirWalkerFile.walk().

156  def cd(self, *args):
157  len_args=len(args)
158  full_url=""
159  if len_args!=1 and len_args!=3:
160  raise InvalidNumberOfArguments
161  if len_args==3:
162  dataset, run, folder = args
163  full_url='%s/data/json/archive/%s/%s/%s' % (self.server, dataset, run, folder)
164  if len_args==1:
165  folder=args[0]
166  if folder==self.DQMpwd:
167  full_url=self.DQMpwd
168  elif folder=="..":
169  full_url=self.DQMpwd[:self.DQMpwd.rfind("/")]
170  elif folder=="-":
171  full_url=self.oldDQMpwd
172  elif folder=="":
173  full_url=DQMcommunicator.base_dir
174  else:
175  full_url=self.DQMpwd+"/"+folder
176 
177  full_url=full_url.replace(' ','%20')
178  #print "cd: "+full_url
179 
180  self.oldDQMpwd=self.DQMpwd
181  self.DQMpwd=full_url
182  #print "In %s" %self.DQMpwd
183 
def dqm_interfaces.DQMcommunicator.get_common_runs (   self,
  dataset_string1,
  dataset_string2 
)

Definition at line 239 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_runs_list().

239  def get_common_runs(self,dataset_string1,dataset_string2):
240  set1=set(self.get_runs_list(dataset_string1))
241  set2=set(self.get_runs_list(dataset_string2))
242  set1.intersection_update(set2)
243  return list (set2)
244 
def get_common_runs(self, dataset_string1, dataset_string2)
def get_runs_list(self, dataset_string)
def dqm_interfaces.DQMcommunicator.get_data (   self,
  full_url 
)

Definition at line 89 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.open_url().

Referenced by dqm_interfaces.DQMcommunicator.get_samples(), and dqm_interfaces.DQMcommunicator.ls_url().

89  def get_data(self, full_url):
90  #print "getting data from %s" %full_url
91  data = self.open_url(full_url).read()
92 
93  data = sub("-inf", '0', data)
94  data = sub("\s+inf", '0', data)
95  data = sub("\s+nan", '0', data)
96  data = sub('""(CMSSW.*?)""', '"\\1"', data)
97 
98  return data
99 
def get_data(self, full_url)
def dqm_interfaces.DQMcommunicator.get_dataset_runs (   self,
  dataset_string 
)

Definition at line 231 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_datasets_list(), and dqm_interfaces.DQMcommunicator.get_runs_list().

231  def get_dataset_runs(self,dataset_string):
232  dataset_runs={}
233  for dataset in self.get_datasets_list(dataset_string):
234  dataset_runs[dataset]=self.get_runs_list(dataset)
235  return dataset_runs
236 
def get_datasets_list(self, dataset_string="")
def get_dataset_runs(self, dataset_string)
def get_runs_list(self, dataset_string)
def dqm_interfaces.DQMcommunicator.get_datasets_list (   self,
  dataset_string = "" 
)

Definition at line 197 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_samples(), and genParticles_cff.map.

Referenced by dqm_interfaces.DQMcommunicator.get_dataset_runs(), and dqm_interfaces.DQMcommunicator.get_RelVal_CMSSW_versions().

197  def get_datasets_list(self, dataset_string=""):
198  samples_list=self.get_samples(dataset_string)
199  datasets_list=[]
200  for sample in samples_list:
201  temp_datasets_list = map(lambda item:item["dataset"] ,sample['items'])
202  for temp_dataset in temp_datasets_list:
203  if not temp_dataset in datasets_list:
204  datasets_list.append(temp_dataset)
205  return datasets_list
206 
def get_datasets_list(self, dataset_string="")
def get_samples(self, samples_string="*")
def dqm_interfaces.DQMcommunicator.get_RelVal_CMSSW_versions (   self,
  query 
)
Get the available cmssw versions for the relvals.

Definition at line 209 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_datasets_list(), and list().

209  def get_RelVal_CMSSW_versions(self,query):
210  """Get the available cmssw versions for the relvals.
211  """
212  relvals_list=self.get_datasets_list(query)
213  # The samples are of the form /RelValTHISISMYFAVOURITECHANNEL/CMSSW_VERSION/GEN-SIM-WHATEVER-RECO
214  cmssw_versions_with_duplicates=map (lambda x: x.split("/")[2],relvals_list)
215  return list(set(cmssw_versions_with_duplicates))
216 
def get_datasets_list(self, dataset_string="")
def get_RelVal_CMSSW_versions(self, query)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def dqm_interfaces.DQMcommunicator.get_root_objects (   self,
  url = "" 
)

Definition at line 261 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, mps_monitormerge.items, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and dqm_interfaces.DQMcommunicator.server.

261  def get_root_objects(self, url=""):
262  if len(url)==0:
263  url=self.DQMpwd
264  else:
265  url=self.server+"/"+url
266  url = url.replace(" ","%20")
267  objects={}
268  for name,description in self.ls(url,True).items():
269  if "dir" not in description["type"] and "ROOT" in description["kind"]:
270  objects[name]=literal2root(description["obj_as_string"],description["type"])
271  return objects
272 
def literal2root(literal, rootType, debug=False)
Definition: ROOTData.py:52
def ls(self, url='', fetch_root=False)
def get_root_objects(self, url="")
def dqm_interfaces.DQMcommunicator.get_root_objects_list (   self,
  url = "" 
)

Definition at line 247 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, mps_monitormerge.items, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

247  def get_root_objects_list(self, url=""):
248  if len(url)==0:
249  url=self.DQMpwd
250  else:
251  url="/"+url
252  url = url.replace(" ","%20")
253  objects=[]
254  for name,description in self.ls(url,True).items():
255  if "dir" not in description["type"] and "ROOT" in description["kind"]:
256  objects.append(literal2root(description["obj_as_string"],description["type"]))
257  return objects
258 
def literal2root(literal, rootType, debug=False)
Definition: ROOTData.py:52
def ls(self, url='', fetch_root=False)
def get_root_objects_list(self, url="")
def dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive (   self,
  url = "" 
)

Definition at line 275 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), python.rootplot.utilities.RootFile.cd(), DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), mps_monitormerge.items, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive().

276  null_url = (len(url)==0)
277  if len(url)==0:
278  url=self.DQMpwd
279  else:
280  url="/"+url
281  url = url.replace(" ","%20")
282  if not null_url:
283  self.cd(url)
284  objects=[]
285  for name,description in self.ls("",True).items():
286  if "dir" in description["type"]:
287  objects+=self.get_root_objects_list_recursive(name)
288  self.cd("..")
289  elif "ROOT" in description["kind"]:
290  objects.append(literal2root(description["obj_as_string"],description["type"]))
291  if not null_url:
292  self.cd("..")
293  return objects
294 
def literal2root(literal, rootType, debug=False)
Definition: ROOTData.py:52
def ls(self, url='', fetch_root=False)
def get_root_objects_list_recursive(self, url="")
def dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 297 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), python.rootplot.utilities.RootFile.cd(), DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), mps_monitormerge.items, ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive().

297  def get_root_objects_names_list_recursive(self, url="",present_url=""):
298  null_url = (len(url)==0)
299  if (not null_url):
300  if len(present_url)==0:
301  present_url=url
302  else:
303  present_url+="_%s"%url
304  if len(url)==0:
305  url=self.DQMpwd
306  else:
307  url="/"+url
308  url = url.replace(" ","%20")
309  if not null_url:
310  self.cd(url)
311  objects_names=[]
312  for name,description in self.ls("",False).items():
313  if "dir" in description["type"]:
314  objects_names+=self.get_root_objects_names_list_recursive(name,present_url)
315  self.cd("..")
316  elif "ROOT" in description["kind"]:
317  objects_names.append("%s_%s"%(present_url,name))
318  if not null_url:
319  self.cd("..")
320  return objects_names
321 
def ls(self, url='', fetch_root=False)
def get_root_objects_names_list_recursive(self, url="", present_url="")
def dqm_interfaces.DQMcommunicator.get_root_objects_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 324 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), python.rootplot.utilities.RootFile.cd(), DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), mps_monitormerge.items, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_recursive().

324  def get_root_objects_recursive(self, url="",present_url=""):
325  null_url = (len(url)==0)
326  if (not null_url):
327  if len(present_url)==0:
328  present_url=url
329  else:
330  present_url+="_%s"%url
331  if len(url)==0:
332  url=self.DQMpwd
333  else:
334  url="/"+url
335  url = url.replace(" ","%20")
336  #if not null_url:
337  self.cd(url)
338  objects={}
339  for name,description in self.ls("",True).items():
340  if "dir" in description["type"]:
341  objects.update(self.get_root_objects_recursive(name,present_url))
342  self.cd("..")
343  elif "ROOT" in description["kind"]:
344  objects["%s_%s"%(present_url,name)]=literal2root(description["obj_as_string"],description["type"])
345  #if not null_url:
346  self.cd("..")
347  return objects
348 
349 #-------------------------------------------------------------------------------
350 
def literal2root(literal, rootType, debug=False)
Definition: ROOTData.py:52
def ls(self, url='', fetch_root=False)
def get_root_objects_recursive(self, url="", present_url="")
def dqm_interfaces.DQMcommunicator.get_runs_list (   self,
  dataset_string 
)

Definition at line 219 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_samples(), and genParticles_cff.map.

Referenced by dqm_interfaces.DQMcommunicator.get_common_runs(), and dqm_interfaces.DQMcommunicator.get_dataset_runs().

219  def get_runs_list(self, dataset_string):
220  slash="/"
221  while(dataset_string.endswith(slash) or dataset_string.beginswith(slash)):
222  dataset_string=dataset_string.strip("/")
223  samples_list=self.get_samples(dataset_string)
224  runlist=[]
225  # Get all the runs in all the items which are in every sample
226  map( lambda sample: map (lambda item: runlist.append(item['run']), sample['items']), samples_list)
227  return runlist
228 
def get_runs_list(self, dataset_string)
def get_samples(self, samples_string="*")
def dqm_interfaces.DQMcommunicator.get_samples (   self,
  samples_string = "*" 
)
A sample contains, among the other things, a data type, a dataset name 
and a run.

Definition at line 186 of file dqm_interfaces.py.

References data_sources.data_source.get_data(), dqm_interfaces.DQMcommunicator.get_data(), and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.get_datasets_list(), and dqm_interfaces.DQMcommunicator.get_runs_list().

186  def get_samples(self, samples_string="*"):
187  """
188  A sample contains, among the other things, a data type, a dataset name
189  and a run.
190  """
191  full_url='%s/data/json/samples?match=%s' % (self.server, samples_string)
192  samples_dict=eval(self.get_data(full_url))
193  return samples_dict["samples"]
194 
def get_data(self, full_url)
def get_samples(self, samples_string="*")
def dqm_interfaces.DQMcommunicator.ls (   self,
  url = '',
  fetch_root = False 
)

Definition at line 142 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, join(), and dqm_interfaces.DQMcommunicator.ls_url().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects(), dqm_interfaces.DQMcommunicator.get_root_objects_list(), dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DirWalkerFile.walk().

142  def ls(self, url='', fetch_root=False):
143  if len(url)==0:
144  url=join(self.DQMpwd,url)
145 
146  form_folder={}
147 
148  if fetch_root:
149  url='%s?rootcontent=1'%url
150  form_folder=self.ls_url(url)
151 
152  return form_folder
153 
def ls(self, url='', fetch_root=False)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def dqm_interfaces.DQMcommunicator.ls_url (   self,
  url 
)

Definition at line 102 of file dqm_interfaces.py.

References data_sources.data_source.get_data(), dqm_interfaces.DQMcommunicator.get_data(), and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.ls().

102  def ls_url(self, url):
103  url=url.replace(" ","%20")
104  url=self.server+url
105  #print "listing "+url
106  form_folder={}
107  raw_folder=None
108  try:
109  raw_folder=eval(self.get_data(url))
110  except:
111  print "Retrying.."
112  for ntrials in xrange(5):
113  try:
114  if ntrials!=0:
115  sleep(2)
116  #raw_folder=loads(self.get_data(url))
117  raw_folder=eval(self.get_data(url))
118  break
119  except:
120  print "Could not fetch %s. Retrying" %url
121 
122  #raw_folder=loads(self.get_data(url))
123  for content_dict in raw_folder["contents"]:
124  if "subdir" in content_dict:
125  form_folder[content_dict["subdir"]]={"type":'dir'}
126  elif "obj" in content_dict:
127  properties=content_dict["properties"]
128  obj_name=content_dict["obj"]
129  obj_type=properties["type"]
130  obj_kind=properties["kind"]
131  obj_as_string=''
132  if "rootobj" in content_dict:
133  obj_as_string=content_dict["rootobj"]
134  form_folder[obj_name]={'type':obj_type,'obj_as_string':obj_as_string,"kind":obj_kind}
135  #for k,v in form_folder.items():
136  #print "* %s --> %s" %(k,v["type"])
137 
138  return form_folder
139 
def get_data(self, full_url)
def dqm_interfaces.DQMcommunicator.open_url (   self,
  url 
)

Definition at line 74 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.ident, and dqm_interfaces.DQMcommunicator.is_private.

Referenced by dqm_interfaces.DQMcommunicator.get_data().

74  def open_url(self,url):
75  url=url.replace(' ','%20')
76  datareq = Request(url)
77  datareq.add_header('User-agent', self.ident)
78  url_obj=0
79  if not self.is_private:
80  url_obj=self.opener.open(datareq)
81  #url_obj=build_opener(X509CertOpen()).open(datareq)
82  else:
83  url_obj=urlopen(datareq)
84 
85  return url_obj
86 

Member Data Documentation

dqm_interfaces.DQMcommunicator.base_dir
static

Definition at line 58 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.DQMpwd
dqm_interfaces.DQMcommunicator.ident

Definition at line 64 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

dqm_interfaces.DQMcommunicator.is_private

Definition at line 66 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

dqm_interfaces.DQMcommunicator.oldDQMpwd

Definition at line 180 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.cd().

dqm_interfaces.DQMcommunicator.opener

Definition at line 69 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.prevDQMpwd

Definition at line 68 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.server