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 57 of file dqm_interfaces.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 65 of file dqm_interfaces.py.

65  def __init__(self,
66  server,
67  is_private=False,
68  ident="DQMToJson/1.0 python/%d.%d.%d" % version_info[:3]):
69  self.ident = ident
70  self.server = server
71  self.is_private = is_private
72  self.DQMpwd=DQMcommunicator.base_dir
73  self.prevDQMpwd=self.DQMpwd
74  self.opener=None
75  if not self.is_private:
76  self.opener=build_opener(X509CertOpen())

Member Function Documentation

◆ cd()

def dqm_interfaces.DQMcommunicator.cd (   self,
args 
)

Definition at line 161 of file dqm_interfaces.py.

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

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().

◆ get_common_runs()

def dqm_interfaces.DQMcommunicator.get_common_runs (   self,
  dataset_string1,
  dataset_string2 
)

Definition at line 244 of file dqm_interfaces.py.

244  def get_common_runs(self,dataset_string1,dataset_string2):
245  set1=set(self.get_runs_list(dataset_string1))
246  set2=set(self.get_runs_list(dataset_string2))
247  set1.intersection_update(set2)
248  return list (set2)
249 

References dqm_interfaces.DQMcommunicator.get_runs_list().

◆ get_data()

def dqm_interfaces.DQMcommunicator.get_data (   self,
  full_url 
)

Definition at line 94 of file dqm_interfaces.py.

94  def get_data(self, full_url):
95  #print "getting data from %s" %full_url
96  data = self.open_url(full_url).read()
97 
98  data = sub("-inf", '0', data)
99  data = sub("\s+inf", '0', data)
100  data = sub("\s+nan", '0', data)
101  data = sub('""(CMSSW.*?)""', '"\\1"', data)
102 
103  return data
104 

References dqm_interfaces.DQMcommunicator.open_url(), and readEcalDQMStatus.read.

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

◆ get_dataset_runs()

def dqm_interfaces.DQMcommunicator.get_dataset_runs (   self,
  dataset_string 
)

Definition at line 236 of file dqm_interfaces.py.

236  def get_dataset_runs(self,dataset_string):
237  dataset_runs={}
238  for dataset in self.get_datasets_list(dataset_string):
239  dataset_runs[dataset]=self.get_runs_list(dataset)
240  return dataset_runs
241 

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

◆ get_datasets_list()

def dqm_interfaces.DQMcommunicator.get_datasets_list (   self,
  dataset_string = "" 
)

Definition at line 202 of file dqm_interfaces.py.

202  def get_datasets_list(self, dataset_string=""):
203  samples_list=self.get_samples(dataset_string)
204  datasets_list=[]
205  for sample in samples_list:
206  temp_datasets_list = map(lambda item:item["dataset"] ,sample['items'])
207  for temp_dataset in temp_datasets_list:
208  if not temp_dataset in datasets_list:
209  datasets_list.append(temp_dataset)
210  return datasets_list
211 

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().

◆ get_RelVal_CMSSW_versions()

def dqm_interfaces.DQMcommunicator.get_RelVal_CMSSW_versions (   self,
  query 
)
Get the available cmssw versions for the relvals.

Definition at line 214 of file dqm_interfaces.py.

214  def get_RelVal_CMSSW_versions(self,query):
215  """Get the available cmssw versions for the relvals.
216  """
217  relvals_list=self.get_datasets_list(query)
218  # The samples are of the form /RelValTHISISMYFAVOURITECHANNEL/CMSSW_VERSION/GEN-SIM-WHATEVER-RECO
219  cmssw_versions_with_duplicates=map (lambda x: x.split("/")[2],relvals_list)
220  return list(set(cmssw_versions_with_duplicates))
221 

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

◆ get_root_objects()

def dqm_interfaces.DQMcommunicator.get_root_objects (   self,
  url = "" 
)

Definition at line 266 of file dqm_interfaces.py.

266  def get_root_objects(self, url=""):
267  if len(url)==0:
268  url=self.DQMpwd
269  else:
270  url=self.server+"/"+url
271  url = url.replace(" ","%20")
272  objects={}
273  for name,description in self.ls(url,True).items():
274  if "dir" not in description["type"] and "ROOT" in description["kind"]:
275  objects[name]=literal2root(description["obj_as_string"],description["type"])
276  return objects
277 
278  #-------------------------------------------------------------------------------
279 

References dqm_interfaces.DQMcommunicator.DQMpwd, mps_monitormerge.items, ROOTData.literal2root(), WZInterestingEventSelector::event.ls, BeamSpotRcdReader::theBSfromDB.ls, BeamSpotOnlineLegacyRcdReader::theBSOfromDB.ls, BeamSpotOnlineHLTRcdReader::theBSOfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and dqm_interfaces.DQMcommunicator.server.

◆ get_root_objects_list()

def dqm_interfaces.DQMcommunicator.get_root_objects_list (   self,
  url = "" 
)

Definition at line 252 of file dqm_interfaces.py.

252  def get_root_objects_list(self, url=""):
253  if len(url)==0:
254  url=self.DQMpwd
255  else:
256  url="/"+url
257  url = url.replace(" ","%20")
258  objects=[]
259  for name,description in self.ls(url,True).items():
260  if "dir" not in description["type"] and "ROOT" in description["kind"]:
261  objects.append(literal2root(description["obj_as_string"],description["type"]))
262  return objects
263 

References dqm_interfaces.DQMcommunicator.DQMpwd, mps_monitormerge.items, ROOTData.literal2root(), WZInterestingEventSelector::event.ls, BeamSpotRcdReader::theBSfromDB.ls, BeamSpotOnlineHLTRcdReader::theBSOfromDB.ls, BeamSpotOnlineLegacyRcdReader::theBSOfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

◆ get_root_objects_list_recursive()

def dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive (   self,
  url = "" 
)

Definition at line 280 of file dqm_interfaces.py.

280  def get_root_objects_list_recursive(self, url=""):
281  null_url = (len(url)==0)
282  if len(url)==0:
283  url=self.DQMpwd
284  else:
285  url="/"+url
286  url = url.replace(" ","%20")
287  if not null_url:
288  self.cd(url)
289  objects=[]
290  for name,description in self.ls("",True).items():
291  if "dir" in description["type"]:
292  objects+=self.get_root_objects_list_recursive(name)
293  self.cd("..")
294  elif "ROOT" in description["kind"]:
295  objects.append(literal2root(description["obj_as_string"],description["type"]))
296  if not null_url:
297  self.cd("..")
298  return objects
299 
300  #-------------------------------------------------------------------------------
301 

References dqm::implementation::NavigatorBase.cd(), TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), python.rootplot.utilities.RootFile.cd(), dqm::implementation::DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), mps_monitormerge.items, ROOTData.literal2root(), WZInterestingEventSelector::event.ls, BeamSpotOnlineLegacyRcdReader::theBSOfromDB.ls, BeamSpotOnlineHLTRcdReader::theBSOfromDB.ls, BeamSpotRcdReader::theBSfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive().

◆ get_root_objects_names_list_recursive()

def dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 302 of file dqm_interfaces.py.

302  def get_root_objects_names_list_recursive(self, url="",present_url=""):
303  null_url = (len(url)==0)
304  if (not null_url):
305  if len(present_url)==0:
306  present_url=url
307  else:
308  present_url+="_%s"%url
309  if len(url)==0:
310  url=self.DQMpwd
311  else:
312  url="/"+url
313  url = url.replace(" ","%20")
314  if not null_url:
315  self.cd(url)
316  objects_names=[]
317  for name,description in self.ls("",False).items():
318  if "dir" in description["type"]:
319  objects_names+=self.get_root_objects_names_list_recursive(name,present_url)
320  self.cd("..")
321  elif "ROOT" in description["kind"]:
322  objects_names.append("%s_%s"%(present_url,name))
323  if not null_url:
324  self.cd("..")
325  return objects_names
326 
327  #-------------------------------------------------------------------------------
328 

References dqm::implementation::NavigatorBase.cd(), TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), python.rootplot.utilities.RootFile.cd(), dqm::implementation::DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), mps_monitormerge.items, WZInterestingEventSelector::event.ls, BeamSpotOnlineLegacyRcdReader::theBSOfromDB.ls, BeamSpotOnlineHLTRcdReader::theBSOfromDB.ls, BeamSpotRcdReader::theBSfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive().

◆ get_root_objects_recursive()

def dqm_interfaces.DQMcommunicator.get_root_objects_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 329 of file dqm_interfaces.py.

329  def get_root_objects_recursive(self, url="",present_url=""):
330  null_url = (len(url)==0)
331  if (not null_url):
332  if len(present_url)==0:
333  present_url=url
334  else:
335  present_url+="_%s"%url
336  if len(url)==0:
337  url=self.DQMpwd
338  else:
339  url="/"+url
340  url = url.replace(" ","%20")
341  #if not null_url:
342  self.cd(url)
343  objects={}
344  for name,description in self.ls("",True).items():
345  if "dir" in description["type"]:
346  objects.update(self.get_root_objects_recursive(name,present_url))
347  self.cd("..")
348  elif "ROOT" in description["kind"]:
349  objects["%s_%s"%(present_url,name)]=literal2root(description["obj_as_string"],description["type"])
350  #if not null_url:
351  self.cd("..")
352  return objects
353 
354 #-------------------------------------------------------------------------------
355 

References dqm::implementation::NavigatorBase.cd(), TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), python.rootplot.utilities.RootFile.cd(), dqm::implementation::DQMStore.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), mps_monitormerge.items, ROOTData.literal2root(), WZInterestingEventSelector::event.ls, BeamSpotOnlineLegacyRcdReader::theBSOfromDB.ls, BeamSpotOnlineHLTRcdReader::theBSOfromDB.ls, BeamSpotRcdReader::theBSfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, and dqm_interfaces.DQMcommunicator.ls().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_recursive().

◆ get_runs_list()

def dqm_interfaces.DQMcommunicator.get_runs_list (   self,
  dataset_string 
)

Definition at line 224 of file dqm_interfaces.py.

224  def get_runs_list(self, dataset_string):
225  slash="/"
226  while(dataset_string.endswith(slash) or dataset_string.beginswith(slash)):
227  dataset_string=dataset_string.strip("/")
228  samples_list=self.get_samples(dataset_string)
229  runlist=[]
230  # Get all the runs in all the items which are in every sample
231  map( lambda sample: map (lambda item: runlist.append(item['run']), sample['items']), samples_list)
232  return runlist
233 

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().

◆ get_samples()

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 191 of file dqm_interfaces.py.

191  def get_samples(self, samples_string="*"):
192  """
193  A sample contains, among the other things, a data type, a dataset name
194  and a run.
195  """
196  full_url='%s/data/json/samples?match=%s' % (self.server, samples_string)
197  samples_dict=eval(self.get_data(full_url))
198  return samples_dict["samples"]
199 

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().

◆ ls()

def dqm_interfaces.DQMcommunicator.ls (   self,
  url = '',
  fetch_root = False 
)

Definition at line 147 of file dqm_interfaces.py.

147  def ls(self, url='', fetch_root=False):
148  if len(url)==0:
149  url=join(self.DQMpwd,url)
150 
151  form_folder={}
152 
153  if fetch_root:
154  url='%s?rootcontent=1'%url
155  form_folder=self.ls_url(url)
156 
157  return form_folder
158 

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().

◆ ls_url()

def dqm_interfaces.DQMcommunicator.ls_url (   self,
  url 
)

Definition at line 107 of file dqm_interfaces.py.

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

References data_sources.data_source.get_data(), dqm_interfaces.DQMcommunicator.get_data(), edm.print(), FastTimerService_cff.range, and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.ls().

◆ open_url()

def dqm_interfaces.DQMcommunicator.open_url (   self,
  url 
)

Definition at line 79 of file dqm_interfaces.py.

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

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

Referenced by dqm_interfaces.DQMcommunicator.get_data().

Member Data Documentation

◆ base_dir

dqm_interfaces.DQMcommunicator.base_dir
static

Definition at line 63 of file dqm_interfaces.py.

◆ DQMpwd

dqm_interfaces.DQMcommunicator.DQMpwd

◆ ident

dqm_interfaces.DQMcommunicator.ident

Definition at line 66 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

◆ is_private

dqm_interfaces.DQMcommunicator.is_private

Definition at line 68 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

◆ oldDQMpwd

dqm_interfaces.DQMcommunicator.oldDQMpwd

Definition at line 185 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.cd().

◆ opener

dqm_interfaces.DQMcommunicator.opener

Definition at line 71 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

◆ prevDQMpwd

dqm_interfaces.DQMcommunicator.prevDQMpwd

Definition at line 70 of file dqm_interfaces.py.

◆ server

dqm_interfaces.DQMcommunicator.server
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
dataLoader.get_data
def get_data(filename)
Definition: dataLoader.py:191
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
ROOTData.literal2root
def literal2root(literal, rootType, debug=False)
Definition: ROOTData.py:53
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40
list
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
genParticles_cff.map
map
Definition: genParticles_cff.py:11