CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
runTheMatrix.TheMatrix Class Reference
Inheritance diagram for runTheMatrix.TheMatrix:

Public Member Functions

def __init__
 
def complete_predefined
 
def complete_searchInWorkflow
 
def complete_showWorkflow
 
def default
 
def do_clear
 
def do_dumpWorkflowId
 
def do_exit
 
def do_predefined
 
def do_search
 
def do_searchInWorkflow
 
def do_showWorkflow
 
def help_dumpWorkflowId
 
def help_predefined
 
def help_search
 
def help_searchInWorkflow
 
def help_showWorkflow
 

Public Attributes

 matrices_
 
 opt_
 

Static Public Attributes

 do_EOF = do_exit
 
string intro = "Welcome to the Matrix (? for help)"
 
string prompt = "matrix> "
 

Detailed Description

Definition at line 436 of file runTheMatrix.py.

Constructor & Destructor Documentation

def runTheMatrix.TheMatrix.__init__ (   self,
  opt 
)

Definition at line 440 of file runTheMatrix.py.

441  def __init__(self, opt):
442  cmd.Cmd.__init__(self)
443  self.opt_ = opt
444  self.matrices_ = {}
445  tmp = MatrixReader(self.opt_)
446  for what in tmp.files:
447  what = what.replace('relval_','')
448  self.opt_.what = what
449  self.matrices_[what] = MatrixReader(self.opt_)
450  self.matrices_[what].prepare(self.opt_.useInput, self.opt_.refRel,
451  self.opt_.fromScratch)
452  os.system("clear")

Member Function Documentation

def runTheMatrix.TheMatrix.complete_predefined (   self,
  text,
  line,
  start_idx,
  end_idx 
)

Definition at line 470 of file runTheMatrix.py.

471  def complete_predefined(self, text, line, start_idx, end_idx):
472  if text and len(text) > 0:
473  return [t for t in predefinedSet.keys() if t.startswith(text)]
474  else:
475  return predefinedSet.keys()
def runTheMatrix.TheMatrix.complete_searchInWorkflow (   self,
  text,
  line,
  start_idx,
  end_idx 
)

Definition at line 521 of file runTheMatrix.py.

522  def complete_searchInWorkflow(self, text, line, start_idx, end_idx):
523  if text and len(text) > 0:
524  return [t for t in self.matrices_.keys() if t.startswith(text)]
525  else:
526  return self.matrices_.keys()
def runTheMatrix.TheMatrix.complete_showWorkflow (   self,
  text,
  line,
  start_idx,
  end_idx 
)

Definition at line 494 of file runTheMatrix.py.

495  def complete_showWorkflow(self, text, line, start_idx, end_idx):
496  if text and len(text) > 0:
497  return [t for t in self.matrices_.keys() if t.startswith(text)]
498  else:
499  return self.matrices_.keys()
def runTheMatrix.TheMatrix.default (   self,
  inp 
)

Definition at line 461 of file runTheMatrix.py.

References runTheMatrix.TheMatrix.do_exit().

462  def default(self, inp):
463  if inp == 'x' or inp == 'q':
464  return self.do_exit(inp)
def runTheMatrix.TheMatrix.do_clear (   self,
  arg 
)
Clear the screen, put prompt at the top

Definition at line 453 of file runTheMatrix.py.

454  def do_clear(self, arg):
455  """Clear the screen, put prompt at the top"""
456  os.system("clear")
def runTheMatrix.TheMatrix.do_dumpWorkflowId (   self,
  arg 
)

Definition at line 567 of file runTheMatrix.py.

References print(), and str.

568  def do_dumpWorkflowId(self, arg):
569  wflids = arg.split()
570  if len(wflids) == 0:
571  print("dumpWorkflowId [wfl-id1 [...]]")
572  return
573 
574  fmt = "[%d]: %s\n"
575  maxLen = 100
576  for wflid in wflids:
577  dump = True
578  for key, mrd in self.matrices_.items():
579  for wfl in mrd.workFlows:
580  if wfl.numId == float(wflid):
581  wfName, stepNames = wfl.nameId.split('+',1)
582  if dump:
583  dump = False
584  print(wfl.numId, stepNames)
585  for i,s in enumerate(wfl.cmds):
586  print(fmt % (i+1, (str(s)+' ')))
587  print("\nWorkflow found in %s." % key)
588  else:
589  print("Workflow also found in %s." % key)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
def runTheMatrix.TheMatrix.do_exit (   self,
  arg 
)

Definition at line 457 of file runTheMatrix.py.

References print().

Referenced by runTheMatrix.TheMatrix.default().

458  def do_exit(self, arg):
459  print("Leaving the Matrix")
460  return True
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runTheMatrix.TheMatrix.do_predefined (   self,
  arg 
)
Print the list of predefined workflows

Definition at line 476 of file runTheMatrix.py.

References print().

477  def do_predefined(self, arg):
478  """Print the list of predefined workflows"""
479  print("List of predefined workflows")
480  if arg:
481  for w in arg.split():
482  if w in predefinedSet.keys():
483  print("Predefined Set: %s" % w)
484  print(predefinedSet[w])
485  else:
486  print("Unknown Set: %s" % w)
487  else:
488  print(predefinedSet.keys())
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runTheMatrix.TheMatrix.do_search (   self,
  arg 
)

Definition at line 555 of file runTheMatrix.py.

References runTheMatrix.TheMatrix.do_searchInWorkflow(), join(), and print().

556  def do_search(self, arg):
557  args = arg.split()
558  if len(args) < 1:
559  print("search regexp")
560  return
561  for wfl in self.matrices_.keys():
562  self.do_searchInWorkflow(' '.join([wfl, args[0]]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def runTheMatrix.TheMatrix.do_searchInWorkflow (   self,
  arg 
)

Definition at line 527 of file runTheMatrix.py.

References runTheMatrix.TheMatrix.matrices_, and print().

Referenced by runTheMatrix.TheMatrix.do_search().

528  def do_searchInWorkflow(self, arg):
529  args = arg.split()
530  if len(args) < 2:
531  print("searchInWorkflow name regexp")
532  return
533  if args[0] not in self.matrices_.keys():
534  print("Unknown workflow")
535  return
536  import re
537  pattern = None
538  try:
539  pattern = re.compile(args[1])
540  except:
541  print("Failed to compile regexp %s" % args[1])
542  return
543  counter = 0
544  for wfl in self.matrices_[args[0]].workFlows:
545  wfName, stepNames = wfl.nameId.split('+',1)
546  if re.match(pattern, wfName) or re.match(pattern, stepNames):
547  print("%s %s %s" % (wfl.numId, wfName, stepNames))
548  counter += 1
549  print("Found %d compatible workflows inside %s" % (counter, args[0]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runTheMatrix.TheMatrix.do_showWorkflow (   self,
  arg 
)

Definition at line 500 of file runTheMatrix.py.

References runTheMatrix.TheMatrix.matrices_, and print().

501  def do_showWorkflow(self, arg):
502  if arg == '':
503  print("Available workflows:")
504  for k in self.matrices_.keys():
505  print(k)
506  else:
507  selected = arg.split()
508  for k in selected:
509  if k not in self.matrices_.keys():
510  print("Unknown workflow %s: skipping" % k)
511  else:
512  for wfl in self.matrices_[k].workFlows:
513  wfName, stepNames = wfl.nameId.split('+',1)
514  print("%s %s %s" % (wfl.numId, wfName, stepNames))
515  print("%s contains %d workflows" % (k, len(self.matrices_[k].workFlows)))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runTheMatrix.TheMatrix.help_dumpWorkflowId (   self)

Definition at line 563 of file runTheMatrix.py.

References join(), and print().

564  def help_dumpWorkflowId(self):
565  print("\n".join(["dumpWorkflowId [wfl-id1 [...]]\n",
566  "Dumps the details (cmsDriver commands for all steps) of the space-separated workflow-ids in input."]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def runTheMatrix.TheMatrix.help_predefined (   self)

Definition at line 465 of file runTheMatrix.py.

References join(), and print().

466  def help_predefined(self):
467  print("\n".join(["predefined [predef1 [...]]\n",
468  "Run w/o argument, it will print the list of known predefined workflows.",
469  "Run with space-separated predefined workflows, it will print the workflow-ids registered to them"]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def runTheMatrix.TheMatrix.help_search (   self)

Definition at line 550 of file runTheMatrix.py.

References join(), and print().

551  def help_search(self):
552  print("\n".join(["search search_regexp\n",
553  "This command will search for a match within all workflows registered.",
554  "The search is done on both the workflow name and the names of steps registered to it."]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def runTheMatrix.TheMatrix.help_searchInWorkflow (   self)

Definition at line 516 of file runTheMatrix.py.

References join(), and print().

517  def help_searchInWorkflow(self):
518  print("\n".join(["searchInWorkflow wfl_name search_regexp\n",
519  "This command will search for a match within all workflows registered to wfl_name.",
520  "The search is done on both the workflow name and the names of steps registered to it."]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def runTheMatrix.TheMatrix.help_showWorkflow (   self)

Definition at line 489 of file runTheMatrix.py.

References join(), and print().

490  def help_showWorkflow(self):
491  print("\n".join(["showWorkflow [workflow1 [...]]\n",
492  "Run w/o arguments, it will print the list of registered macro-workflows.",
493  "Run with space-separated workflows, it will print the full list of workflow-ids registered to them"]))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

Member Data Documentation

runTheMatrix.TheMatrix.do_EOF = do_exit
static

Definition at line 590 of file runTheMatrix.py.

string runTheMatrix.TheMatrix.intro = "Welcome to the Matrix (? for help)"
static

Definition at line 437 of file runTheMatrix.py.

runTheMatrix.TheMatrix.matrices_

Definition at line 443 of file runTheMatrix.py.

Referenced by runTheMatrix.TheMatrix.do_searchInWorkflow(), and runTheMatrix.TheMatrix.do_showWorkflow().

runTheMatrix.TheMatrix.opt_

Definition at line 442 of file runTheMatrix.py.

string runTheMatrix.TheMatrix.prompt = "matrix> "
static

Definition at line 438 of file runTheMatrix.py.