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 63 of file getPayloadData.py.

References createfilelist.int, and output().

Referenced by output().

63 def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs):
64  ''' Deserializes given iovs data and returns plot coordinates '''
65 
66  output('Starting to deserialize iovs: ', '')
67  output('db: ', db)
68  output('plugin name: ', plugin_name)
69  output('plot name: ', plot_name)
70  output('tag name: ', tag)
71  output('tag time type: ', time_type)
72  output('iovs: ', iovs)
73 
74  plugin_base = import_module('pluginModule_PayloadInspector')
75  output('PI plugin base: ', plugin_base)
76 
77  plugin_obj = import_module(plugin_name)
78  output('PI plugin object: ', plugin_obj)
79 
80  # get plot method and execute it with given iovs
81  plot = getattr(plugin_obj, plot_name)()
82  output('plot object: ', plot)
83 
84  if db == "Prod":
85  db_name = 'frontier://FrontierProd/CMS_CONDITIONS'
86  elif db == 'Prep' :
87  db_name = 'frontier://FrontierPrep/CMS_CONDITIONS'
88  else:
89  db_name = db
90  output('full DB name: ', db_name)
91 
92 
93  success = plot.process(db_name, tag, time_type, int(iovs['start_iov']), int(iovs['end_iov']))
94  output('plot processed data successfully: ', success)
95  if not success:
96  return False
97 
98 
99  result = plot.data()
100  output('deserialized data: ', result)
101  return result
102 
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 139 of file getPayloadData.py.

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

Referenced by output().

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

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

Referenced by discover().

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

Definition at line 176 of file getPayloadData.py.

References deserialize_iovs(), discover(), and harvestTrackValidationPlots.str.

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

176 def output(description, param):
177  if args.verbose:
178  print ''
179  print description, param
180 
def output(description, param)
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 20 of file getPayloadData.py.

References f.

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