CMS 3D CMS Logo

Functions
util.getRunInfo Namespace Reference

Functions

def dasQuery (queryString, entryTitle)
 
def dasRunQueryToDict (querystring)
 
def day (string)
 
def daysAgo (n)
 
def getFilesForRun (run, dataset)
 
def getRunsForDate (date, minlumis=10)
 
def getRunsNewer (run, minlumis=10, source='RunRegistry')
 
def runGetDatasetsAvailable (run)
 
def today ()
 

Function Documentation

def util.getRunInfo.dasQuery (   queryString,
  entryTitle 
)

Definition at line 74 of file getRunInfo.py.

Referenced by util.getRunInfo.dasRunQueryToDict(), util.getRunInfo.getFilesForRun(), and util.getRunInfo.runGetDatasetsAvailable().

74 def dasQuery(queryString, entryTitle) :
75  dasinfo = das_client.get_data('https://cmsweb.cern.ch', queryString, 0, 0, False)
76  if dasinfo['status'] != 'ok' :
77  raise Exception('DAS query failed.\nQuery: %s\nDAS Status returned: %s' % (queryString, dasinfo['status']))
78 
79  if len(dasinfo['data']) > 0 :
80  for entry in dasinfo['data'] :
81  if entryTitle in entry and len(entry[entryTitle]) > 0 :
82  yield entry[entryTitle][0]
83 
def dasQuery(queryString, entryTitle)
Definition: getRunInfo.py:74
def util.getRunInfo.dasRunQueryToDict (   querystring)

Definition at line 66 of file getRunInfo.py.

References util.getRunInfo.dasQuery(), and createfilelist.int.

Referenced by util.getRunInfo.getRunsForDate(), and util.getRunInfo.getRunsNewer().

66 def dasRunQueryToDict(querystring) :
67  runs = {}
68  for runDict in dasQuery(querystring, 'run') :
69  runNo = int(runDict['run_number'])
70  runDict['date'] = datestring
71  runs[runNo] = runDict
72  return runs
73 
def dasRunQueryToDict(querystring)
Definition: getRunInfo.py:66
def dasQuery(queryString, entryTitle)
Definition: getRunInfo.py:74
def util.getRunInfo.day (   string)
def util.getRunInfo.daysAgo (   n)

Definition at line 7 of file getRunInfo.py.

References util.getRunInfo.today().

7 def daysAgo(n) :
8  date = today()
9  return date - datetime.timedelta(days=n)
10 
def daysAgo(n)
Definition: getRunInfo.py:7
def util.getRunInfo.getFilesForRun (   run,
  dataset 
)
    run : int
    dataset : string dataset to find files in, e.g.
        /ExpressCosmics/Run2015A-Express-v1/FEVT
        /ExpressPhysics/Run2015A-Express-v1/FEVT

Definition at line 47 of file getRunInfo.py.

References util.getRunInfo.dasQuery(), and alcaDQMUpload.encode().

47 def getFilesForRun(run, dataset) :
48  '''
49  run : int
50  dataset : string dataset to find files in, e.g.
51  /ExpressCosmics/Run2015A-Express-v1/FEVT
52  /ExpressPhysics/Run2015A-Express-v1/FEVT
53  '''
54  querystring = "file dataset={dataset} run={run}".format(dataset=dataset, run=run)
55 
56  files = []
57  for fileDict in dasQuery(querystring, 'file') :
58  # cmsRun will not like unicode
59  files.append(fileDict['name'].encode('ascii','replace'))
60 
61  return files
62 
63 
64 # -------------------- DAS convert tools
65 
def getFilesForRun(run, dataset)
Definition: getRunInfo.py:47
def encode(args, files)
def dasQuery(queryString, entryTitle)
Definition: getRunInfo.py:74
def util.getRunInfo.getRunsForDate (   date,
  minlumis = 10 
)
    date: expected to be datetime.datetime object

Definition at line 14 of file getRunInfo.py.

References util.getRunInfo.dasRunQueryToDict().

14 def getRunsForDate(date, minlumis=10) :
15  '''
16  date: expected to be datetime.datetime object
17  '''
18  datestring = date.strftime('%Y%m%d')
19  querystring = "run date={date} | grep run.nlumis>{minlumis}".format(date=datestring, minlumis=minlumis)
20  return dasRunQueryToDict(querystring)
21 
def getRunsForDate(date, minlumis=10)
Definition: getRunInfo.py:14
def dasRunQueryToDict(querystring)
Definition: getRunInfo.py:66
def util.getRunInfo.getRunsNewer (   run,
  minlumis = 10,
  source = 'RunRegistry' 
)
    run: run number int
    source: Either RunRegistry or DAS

Definition at line 22 of file getRunInfo.py.

References util.getRunInfo.dasRunQueryToDict().

22 def getRunsNewer(run, minlumis=10, source='RunRegistry') :
23  '''
24  run: run number int
25  source: Either RunRegistry or DAS
26  '''
27  if source == 'RunRegistry' :
28  return rrClient.getRunsNewer(run, minlumis)
29  elif source == 'DAS' :
30  querystring = "run | grep run.nlumis>{minlumis}, run.runnumber>{run}".format(run=run, minlumis=minlumis)
31  return dasRunQueryToDict(querystring)
32 
def dasRunQueryToDict(querystring)
Definition: getRunInfo.py:66
def getRunsNewer(run, minlumis=10, source='RunRegistry')
Definition: getRunInfo.py:22
def util.getRunInfo.runGetDatasetsAvailable (   run)
    run : int
    Will return a list of datasets in DAS that have the run in them

Definition at line 33 of file getRunInfo.py.

References util.getRunInfo.dasQuery(), and alcaDQMUpload.encode().

34  '''
35  run : int
36  Will return a list of datasets in DAS that have the run in them
37  '''
38  querystring = "dataset run={run}".format(run=run)
39 
40  datasets = []
41  for datasetDict in dasQuery(querystring, 'dataset') :
42  # cmsRun will not like unicode
43  datasets.append(datasetDict['name'].encode('ascii','replace'))
44 
45  return datasets
46 
def encode(args, files)
def runGetDatasetsAvailable(run)
Definition: getRunInfo.py:33
def dasQuery(queryString, entryTitle)
Definition: getRunInfo.py:74
def util.getRunInfo.today ( )

Definition at line 4 of file getRunInfo.py.

References indexGen.date.

Referenced by util.getRunInfo.daysAgo().

4 def today() :
5  return datetime.datetime.now().date()
6