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

◆ dasQuery()

def util.getRunInfo.dasQuery (   queryString,
  entryTitle 
)

Definition at line 74 of file getRunInfo.py.

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]

References das_client.get_data().

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

◆ dasRunQueryToDict()

def util.getRunInfo.dasRunQueryToDict (   querystring)

Definition at line 66 of file getRunInfo.py.

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 

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

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

◆ day()

def util.getRunInfo.day (   string)

◆ daysAgo()

def util.getRunInfo.daysAgo (   n)

Definition at line 7 of file getRunInfo.py.

7 def daysAgo(n) :
8  date = today()
9  return date - datetime.timedelta(days=n)
10 

References util.getRunInfo.today().

◆ getFilesForRun()

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.

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 

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

◆ getRunsForDate()

def util.getRunInfo.getRunsForDate (   date,
  minlumis = 10 
)
    date: expected to be datetime.datetime object

Definition at line 14 of file getRunInfo.py.

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 

References util.getRunInfo.dasRunQueryToDict().

◆ getRunsNewer()

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.

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 

References util.getRunInfo.dasRunQueryToDict().

◆ runGetDatasetsAvailable()

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.

33 def runGetDatasetsAvailable(run) :
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 

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

◆ today()

def util.getRunInfo.today ( )

Definition at line 4 of file getRunInfo.py.

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

References indexGen.date.

Referenced by util.getRunInfo.daysAgo().

util.getRunInfo.getRunsNewer
def getRunsNewer(run, minlumis=10, source='RunRegistry')
Definition: getRunInfo.py:22
util.getRunInfo.today
def today()
Definition: getRunInfo.py:4
util.getRunInfo.getRunsForDate
def getRunsForDate(date, minlumis=10)
Definition: getRunInfo.py:14
util.getRunInfo.dasRunQueryToDict
def dasRunQueryToDict(querystring)
Definition: getRunInfo.py:66
util.getRunInfo.getFilesForRun
def getFilesForRun(run, dataset)
Definition: getRunInfo.py:47
Exception
util.getRunInfo.runGetDatasetsAvailable
def runGetDatasetsAvailable(run)
Definition: getRunInfo.py:33
createfilelist.int
int
Definition: createfilelist.py:10
util.getRunInfo.daysAgo
def daysAgo(n)
Definition: getRunInfo.py:7
util.getRunInfo.day
def day(string)
Definition: getRunInfo.py:11
das_client.get_data
def get_data(host, query, idx, limit, debug, threshold=300, ckey=None, cert=None, capath=None, qcache=0, das_headers=True)
Definition: das_client.py:275
indexGen.date
date
Definition: indexGen.py:99
util.getRunInfo.dasQuery
def dasQuery(queryString, entryTitle)
Definition: getRunInfo.py:74
alcaDQMUpload.encode
def encode(args, files)
Definition: alcaDQMUpload.py:32
format