CMS 3D CMS Logo

Functions
getPayloadData Namespace Reference

Functions

def deserialize_iovs (db, plugin_name, plot_name, tag, time_type, iovs)
 
def discover ()
 
def discover_plugins ()
 
def output (description, param)
 
def supress_output (f)
 

Function Documentation

def getPayloadData.deserialize_iovs (   db,
  plugin_name,
  plot_name,
  tag,
  time_type,
  iovs 
)
Deserializes given iovs data and returns plot coordinates 

Definition at line 64 of file getPayloadData.py.

References createfilelist.int, and output().

Referenced by output().

64 def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs):
65  ''' Deserializes given iovs data and returns plot coordinates '''
66 
67  output('Starting to deserialize iovs: ', '')
68  output('db: ', db)
69  output('plugin name: ', plugin_name)
70  output('plot name: ', plot_name)
71  output('tag name: ', tag)
72  output('tag time type: ', time_type)
73  output('iovs: ', iovs)
74 
75  plugin_base = import_module('pluginModule_PayloadInspector')
76  output('PI plugin base: ', plugin_base)
77 
78  plugin_obj = import_module(plugin_name)
79  output('PI plugin object: ', plugin_obj)
80 
81  # get plot method and execute it with given iovs
82  plot = getattr(plugin_obj, plot_name)()
83  output('plot object: ', plot)
84 
85  if db == "Prod":
86  db_name = 'frontier://FrontierProd/CMS_CONDITIONS'
87  elif db == 'Prep' :
88  db_name = 'frontier://FrontierPrep/CMS_CONDITIONS'
89  else:
90  db_name = db
91  output('full DB name: ', db_name)
92 
93 
94  success = plot.process(db_name, tag, time_type, int(iovs['start_iov']), int(iovs['end_iov']))
95  output('plot processed data successfully: ', success)
96  if not success:
97  return False
98 
99 
100  result = plot.data()
101  output('deserialized data: ', result)
102  return result
103 
def output(description, param)
def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs)
def getPayloadData.discover ( )
Discovers object types and plots for a given cmssw release
    Example:
    {
        "BasicPayload": [
            {"plot": "plot_BeamSpot_x", "plot_type": "History", 
             "single_iov": false, "plugin_name": "pluginBeamSpot_PayloadInspector",
             "title": "x vs run number"},
            ...
        ],
       ...
    }

Definition at line 140 of file getPayloadData.py.

References mps_setup.append, dir, discover_plugins(), and output().

Referenced by output().

140 def discover():
141  ''' Discovers object types and plots for a given cmssw release
142  Example:
143  {
144  "BasicPayload": [
145  {"plot": "plot_BeamSpot_x", "plot_type": "History",
146  "single_iov": false, "plugin_name": "pluginBeamSpot_PayloadInspector",
147  "title": "x vs run number"},
148  ...
149  ],
150  ...
151  }
152  '''
153  plugin_base = import_module('pluginModule_PayloadInspector')
154  result = {}
155  for plugin_name in discover_plugins():
156  output(' - plugin name: ', plugin_name)
157  plugin_obj = import_module(plugin_name)
158  output('*** PI plugin object: ', plugin_obj)
159  for plot in dir(plugin_obj):
160  if 'plot_' not in plot: continue # skip if method doesn't start with 'plot_' prefix
161  output(' - plot name: ', plot)
162  plot_method= getattr(plugin_obj, plot)()
163  output(' - plot object: ', plot_method)
164  payload_type = plot_method.payloadType()
165  output(' - payload type: ', payload_type)
166  plot_title = plot_method.title()
167  output(' - plot title: ', plot_title)
168  plot_type = plot_method.type()
169  output(' - plot type: ', plot_type)
170  single_iov = plot_method.isSingleIov()
171  output(' - is single iov: ', single_iov)
172  result.setdefault(payload_type, []).append({'plot': plot, 'plugin_name': plugin_name, 'title': plot_title, 'plot_type': plot_type, 'single_iov': single_iov})
173  output('currently discovered info: ', result)
174  output('*** final output:', '')
175  return json.dumps(result)
176 
def output(description, param)
dbl *** dir
Definition: mlp_gen.cc:35
def getPayloadData.discover_plugins ( )
Returns a list of Payload Inspector plugin names
    Example:
    ['pluginBasicPayload_PayloadInspector', 'pluginBeamSpot_PayloadInspector', 'pluginSiStrip_PayloadInspector']

Definition at line 104 of file getPayloadData.py.

References output(), and python.rootplot.root2matplotlib.replace().

Referenced by discover().

105  ''' Returns a list of Payload Inspector plugin names
106  Example:
107  ['pluginBasicPayload_PayloadInspector', 'pluginBeamSpot_PayloadInspector', 'pluginSiStrip_PayloadInspector']
108  '''
109  architecture = os.environ.get('SCRAM_ARCH', None)
110  output('architecture: ', architecture)
111 
112  plugins = []
113  releases = [
114  os.environ.get('CMSSW_BASE', None),
115  os.environ.get('CMSSW_RELEASE_BASE', None)
116  ]
117 
118  for r in releases:
119  if not r: continue # skip if release base is not specified
120  output('* release: ', r)
121 
122  path = os.path.join(r, 'lib', architecture)
123  output('* full release path: ', path)
124 
125  plugins += glob.glob(path + '/plugin*_PayloadInspector.so' )
126  output('found plugins: ', plugins)
127 
128  if r: break # break loop if CMSSW_BASE is specified
129 
130  # extracts the object name from plugin path:
131  # /afs/cern.ch/cms/slc6_amd64_gcc493/cms/cmssw/CMSSW_8_0_6/lib/slc6_amd64_gcc493/pluginBasicPayload_PayloadInspector.so
132  # becomes pluginBasicPayload_PayloadInspector
133  result = []
134  for p in plugins:
135  result.append(p.split('/')[-1].replace('.so', ''))
136 
137  output('discovered plugins: ', result)
138  return result
139 
def output(description, param)
def replace(string, replacements)
def getPayloadData.output (   description,
  param 
)

Definition at line 177 of file getPayloadData.py.

References deserialize_iovs(), discover(), edm.print(), and str.

Referenced by deserialize_iovs(), discover(), and discover_plugins().

177 def output(description, param):
178  if args.verbose:
179  print('')
180  print(description, param)
181 
def output(description, param)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def getPayloadData.supress_output (   f)
Temporarily disables stdout and stderr so that printouts from the plot
plugin does not compromise the purity of our ssh stream if 
args.suppress_output is true

Definition at line 21 of file getPayloadData.py.

References f.

21 def supress_output( f ):
22  '''
23  Temporarily disables stdout and stderr so that printouts from the plot
24  plugin does not compromise the purity of our ssh stream if
25  args.suppress_output is true
26  '''
27  def decorated( *fargs, **fkwargs ):
28 
29  suppress = args.suppress_output
30  if suppress:
31 
32  # Get rid of what is already there ( should be nothing for this script )
33  sys.stdout.flush()
34 
35  # Save file descriptors so it can be reactivated later
36  saved_stdout = os.dup( 1 )
37  saved_stderr = os.dup( 2 )
38 
39  # /dev/null is used just to discard what is being printed
40  devnull = os.open( '/dev/null', os.O_WRONLY )
41 
42  # Duplicate the file descriptor for /dev/null
43  # and overwrite the value for stdout (file descriptor 1)
44  os.dup2( devnull, 1 )
45  os.dup2( devnull, 2 )
46 
47  result = f( *fargs, **fkwargs )
48 
49  if suppress:
50 
51  # Close devnull after duplication (no longer needed)
52  os.close( devnull )
53 
54  # Reenable stdout and stderr
55  os.dup2( saved_stdout, 1 )
56  os.dup2( saved_stderr, 2 )
57 
58  return result
59 
60  return decorated
61 
62 
63 @supress_output
def supress_output(f)
double f[11][100]