ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
python.JobProperties.JobPropertyContainer Class Reference
Inheritance diagram for python.JobProperties.JobPropertyContainer:
Collaboration diagram for python.JobProperties.JobPropertyContainer:

Public Member Functions

def __init__ (self, context='')
 
def __setattr__ (self, name, n_value)
 
def __str__ (self)
 
def is_locked (self)
 
def help (self)
 
def import_JobProperties (self, module_name)
 
def import_Flags (self, module_name)
 
def add_Container (self, new_container)
 
def add_JobProperty (self, new_flag)
 
def del_JobProperty (self, del_flag)
 
def del_Container (self, del_container)
 
def lock_JobProperties (self)
 
def unlock_JobProperties (self)
 
def print_JobProperties (self, mode='minimal')
 
def set_JobProperties (self, data)
 
def __getattribute__ (self, name)
 

Private Attributes

 __name__
 
 _context_name
 

Static Private Attributes

 _log = Logging.logging.getLogger('JobPropertyContainer::')
 
 _nInstancesContextList = list()
 
bool _locked = False
 

Detailed Description

Container for the JobProperties. 

     By definition it will contain a minimal set of flags,
   but this set can be increased during the job configuration
   using the "import_JobProperties" or "add_JobProperty" 
   methods. In this way it can be adapted to the diferent 
   job needs.
     A JobPropertyContainer can contain other JobProperty 
   containers, that can be added using the "add_Container" 
   method.
     There is a top global job properties container instance 
   which is called "jobproperties" that has to be used as starting
   point. 

Definition at line 444 of file JobProperties.py.

Constructor & Destructor Documentation

◆ __init__()

def python.JobProperties.JobPropertyContainer.__init__ (   self,
  context = '' 
)
Each JobPropertyContainer has only one possible instance
    in a given context.

Definition at line 464 of file JobProperties.py.

464  def __init__(self,context=''):
465  """ Each JobPropertyContainer has only one possible instance
466  in a given context.
467  """
468  if context=='':
469  context_name=self.__class__.__name__
470  else:
471  context_name=context+'.'+self.__class__.__name__
472  if not (context_name in self.__class__._nInstancesContextList):
473  self.__class__._nInstancesContextList.append(context_name)
474  self.__name__=self.__class__.__name__
475  self._context_name=context_name
476  else:
477  self._log.error('There is already an instance of %s at %s',
478  self.__class__.__name__, context_name)
479  raise RuntimeError('JobProperties:JobPropertyContainer: __init__()')
480 

Member Function Documentation

◆ __getattribute__()

def python.JobProperties.JobPropertyContainer.__getattribute__ (   self,
  name 
)

Definition at line 757 of file JobProperties.py.

757  def __getattribute__(self,name):
758  try:
759  return object.__getattribute__(self, name)
760  except AttributeError:
761 
762  errString="JobPropertyContainer:: %s does not have property %s" % (object.__getattribute__(self,'_context_name'), name)
763  allattrs=object.__getattribute__(self,'__dict__').keys()
764  from difflib import get_close_matches
765  closestMatch=get_close_matches(name,allattrs,1)
766  if len(closestMatch)>0:
767  errString+=". Did you mean \'%s\'?" % closestMatch[0]
768  raise AttributeError(errString)
769  pass
770 
771 
772 #=======================================================================
773 # data
774 #=======================================================================

◆ __setattr__()

def python.JobProperties.JobPropertyContainer.__setattr__ (   self,
  name,
  n_value 
)

Definition at line 481 of file JobProperties.py.

481  def __setattr__(self, name, n_value):
482  # Protection for the already defined JobProperties classes
483  # and inmediate asignation of a new StoredValue
484  if not(name=='__name__' or name=='_context_name' or name=='_locked'):
485  if (issubclass(n_value.__class__,JobProperty) or
486  issubclass(n_value.__class__,JobPropertyContainer)):
487  pass
488  elif(self.__dict__.__contains__(name)):
489  pass
490  else:
491  errString="JobPropertyContainer:: %s does not have property %s" % (self._context_name, name)
492  try:
493  from difflib import get_close_matches
494  closestMatch=get_close_matches(name,self.__dict__.keys(),1)
495  if len(closestMatch)>0:
496  errString+=". Did you mean \'%s\'?" % closestMatch[0]
497  except Exception:
498  pass #No execption from here
499 
500  raise AttributeError(errString)
501  try:
502  protected=hasattr(self.__dict__[name],'_context_name')
503  except Exception:
504  protected=False
505  if not protected:
506  self.__dict__[name] = n_value
507  else:
508  property_obj=self.__dict__.get(name)
509  property_obj.StoredValue=n_value
510  property_obj.statusOn=True
511 
512 
513 

◆ __str__()

def python.JobProperties.JobPropertyContainer.__str__ (   self)

Definition at line 514 of file JobProperties.py.

514  def __str__(self):
515  if self._context_name.count('.')==0:
516  # the top container case
517  print_view=' [-]'+self.__name__+'\n'+' | '+'\n'
518  for k in sorted(self.__dict__.keys()):
519  m=self.__dict__.get(k)
520  if hasattr(m,'print_JobProperty'):
521  m.print_JobProperty('print_v')
522  print_view+=str(m)+'\n'
523  elif hasattr(m,'print_JobProperties'):
524  indent='-'
525  for i in range(m._context_name.count('.')-1):
526  indent+='-'
527  print_view+=' /'+indent+'> ## '+m.__name__+' ## '+'\n'
528  print_view+=m.print_JobProperties('print_v')
529  return print_view
530  else:
531  return self.print_JobProperties('print_v')
532 

◆ add_Container()

def python.JobProperties.JobPropertyContainer.add_Container (   self,
  new_container 
)
Adds a container of JobProperties of the type 
   JobPropertyContainer to the existing container. 

Definition at line 590 of file JobProperties.py.

590  def add_Container(self,new_container):
591  """ Adds a container of JobProperties of the type
592  JobPropertyContainer to the existing container.
593  """
594  if issubclass(new_container,JobPropertyContainer):
595  issubclass(new_container,JobPropertyContainer)
596  if not(new_container.__name__ in self.__dict__.keys()):
597  setattr(self,new_container.__name__,
598  new_container(self._context_name))
599  else:
600  self._log.warning('The container %s is already in %s',
601  new_container.__name__,self.__name__)
602  else:
603  self._log.error('You are not adding a JobPropertyContainer ')
604 

◆ add_JobProperty()

def python.JobProperties.JobPropertyContainer.add_JobProperty (   self,
  new_flag 
)
Add one JobProperty to the present container.  

   The new JobProperty added must have a name 
   without '_' and subclass the base class "JobProperty".


Definition at line 605 of file JobProperties.py.

605  def add_JobProperty(self, new_flag):
606  """ Add one JobProperty to the present container.
607 
608  The new JobProperty added must have a name
609  without '_' and subclass the base class "JobProperty".
610  """
611  if issubclass(new_flag,JobProperty):
612  if not(new_flag.__name__ in self.__dict__.keys()):
613  setattr(self,new_flag.__name__,new_flag(self._context_name))
614  else:
615  self._log.warning('The flag %s is already in %s',
616  new_flag.__name__, self.__name__)
617  else:
618  self._log.error('You are not adding a JobProperty ')
619 

◆ del_Container()

def python.JobProperties.JobPropertyContainer.del_Container (   self,
  del_container 
)
Deletes one sub-container of the present container.  


Definition at line 634 of file JobProperties.py.

634  def del_Container(self, del_container):
635  """ Deletes one sub-container of the present container.
636  """
637  if (issubclass(del_container,JobPropertyContainer) and
638  hasattr(self,del_container.__name__)):
639  flagcontainer_obj=getattr(self,del_container.__name__)
640  delattr(self,del_container.__name__)
641  del_container._nInstancesContextList.remove(flagcontainer_obj._context_name)
642  self._log.warning('The JobProperty Container %s has been deleted',
643  del_container.__name__)
644  else:
645  self._log.info('The JobProperty Container %s is not defined here',
646  del_container.__name__)

◆ del_JobProperty()

def python.JobProperties.JobPropertyContainer.del_JobProperty (   self,
  del_flag 
)
Deletes one JobProperty from the present container.

Definition at line 620 of file JobProperties.py.

620  def del_JobProperty(self, del_flag):
621  """ Deletes one JobProperty from the present container.
622  """
623  if (issubclass(del_flag,JobProperty) and
624  hasattr(self,del_flag.__name__)):
625  flag_obj=getattr(self,del_flag.__name__)
626  delattr(self,del_flag.__name__)
627  del_flag._nInstancesContextDict.pop(flag_obj._context_name)
628  self._log.debug('The JobProperty %s has been deleted',
629  del_flag.__name__)
630  else:
631  self._log.info('The JobProperty %s is not defined here',
632  del_flag.__name__)
633 

◆ help()

def python.JobProperties.JobPropertyContainer.help (   self)
Prints the documentation generated with the JobProperty 
    container.  

Definition at line 536 of file JobProperties.py.

536  def help(self):
537  """ Prints the documentation generated with the JobProperty
538  container.
539  """
540  self._log.info('### Help for the class %s ###',
541  self.__class__)
542  self._log.info(self.__doc__)
543  self._log.info('### End of the help for the class %s ###',
544  self.__class__)
545 

◆ import_Flags()

def python.JobProperties.JobPropertyContainer.import_Flags (   self,
  module_name 
)
OBSOLETE: Use import_JobProperties

    Import modules with JobProperties specific to a given job 
   configuration.  
   
   The new specific set of JobProperties added must have a name 
   without '_' and subclass the base class "JobProperty". 

   IMPORTANT: "import_Flags" method is calling the new method 
      "import_JobProperties". For some time import_Flags
       it will work but it will be removed soon

Definition at line 574 of file JobProperties.py.

574  def import_Flags(self,module_name):
575  """ OBSOLETE: Use import_JobProperties
576 
577  Import modules with JobProperties specific to a given job
578  configuration.
579 
580  The new specific set of JobProperties added must have a name
581  without '_' and subclass the base class "JobProperty".
582 
583  IMPORTANT: "import_Flags" method is calling the new method
584  "import_JobProperties". For some time import_Flags
585  it will work but it will be removed soon
586  """
587  self._log.warning('OBSOLETE method: use import_JobProperties')
588  self.import_JobProperties(module_name)
589 

◆ import_JobProperties()

def python.JobProperties.JobPropertyContainer.import_JobProperties (   self,
  module_name 
)
Import modules with JobProperties specific to a given job 
   configuration.  
   
   The new specific set of JobProperties added must have a name 
   without '_' and subclass the base class "JobProperty".

Definition at line 546 of file JobProperties.py.

546  def import_JobProperties(self,module_name):
547  """ Import modules with JobProperties specific to a given job
548  configuration.
549 
550  The new specific set of JobProperties added must have a name
551  without '_' and subclass the base class "JobProperty".
552  """
553  try:
554  if(module_name.count('.')==0):
555  module=__import__(module_name,globals(),locals())
556  elif(module_name.count('.')>0):
557  module=__import__(module_name,globals(),locals(),\
558  ['JobProperties'])
559  except ImportError:
560  import traceback
561  traceback.print_exc()
562  self._log.error(" import_JobProperties: No module named %s",
563  module_name)
564  return None
565  mo=vars(module)
566  p = re.compile('_') # mgallas --> look into this and relax it
567  for i in mo.keys():
568  if(not(p.match(i)) and
569  (i !='JobPropertyContainer' and i!='JobProperty' and
570  i !='jobproperties')):
571  mok=mo.get(i)
572  setattr(self,mok.__name__,mok(self._context_name))
573 

◆ is_locked()

def python.JobProperties.JobPropertyContainer.is_locked (   self)

Definition at line 533 of file JobProperties.py.

533  def is_locked(self):
534  return self._locked
535 

◆ lock_JobProperties()

def python.JobProperties.JobPropertyContainer.lock_JobProperties (   self)
Locks the Values of the JobProperties

Definition at line 647 of file JobProperties.py.

647  def lock_JobProperties(self):
648  """ Locks the Values of the JobProperties
649  """
650  for j in self.__dict__.keys():
651  j_obj=self.__dict__.get(j)
652  if hasattr(j_obj,'lock_JobProperties'):
653  j_obj.lock_JobProperties()
654  j_obj._locked=True
655  elif hasattr(j_obj,'_locked'):
656  j_obj._locked=True
657  self._log.info('The JobProperty Container %s is locked',
658  self.__name__)
659 

◆ print_JobProperties()

def python.JobProperties.JobPropertyContainer.print_JobProperties (   self,
  mode = 'minimal' 
)
Prints all the JobProperties in the container. 

    It will print also the JobProperties within the sub-containers
   present in the container. 

    The available options are: 'minimal','full','tree','tree&value','tree&valuenondefault'

Definition at line 673 of file JobProperties.py.

673  def print_JobProperties(self,mode='minimal'):
674  """Prints all the JobProperties in the container.
675 
676  It will print also the JobProperties within the sub-containers
677  present in the container.
678 
679  The available options are: 'minimal','full','tree','tree&value','tree&valuenondefault'
680  """
681  print_view=''
682  if self._context_name.count('.')==0:
683  additionalinfo=''
684  if (mode=='tree&valuenondefault'):
685  additionalinfo="(Only non default values)"
686  if mode != "minimal":
687  additionalinfo+="(X indicates locked properties)"
688 
689  self._log.info("### Printing the job properties container %s %s ###",
690  self.__name__ ,additionalinfo)
691 
692  if(mode=='tree' or mode.startswith('tree&value')):
693  print (' [-]'+self.__name__)
694  print (' | ')
695  elif(mode=='print_v'):
696  print_view+=' [-]'+self.__name__+'\n'+' | '+'\n'
697  else:
698  self._log.info(' [-]'+self.__name__)
699 
700  for k in sorted(self.__dict__.keys()):
701  m=self.__dict__.get(k)
702  if hasattr(m,'print_JobProperty'):
703  m.print_JobProperty(mode)
704  if mode=='print_v':
705  print_view+=str(m)+'\n'
706  elif hasattr(m,'print_JobProperties'):
707  indent='-'
708  for i in range(m._context_name.count('.')-1):
709  indent+='-'
710  if(mode=='tree' or mode.startswith('tree&value')):
711  print (' /'+indent+'> ## '+m.__name__+' ## ')
712  elif(mode=='print_v'):
713  print_view+=' /'+indent+'> ## '+m.__name__+' ## '+'\n'
714  else:
715  self._log.info(' /'+indent+'> ## '+m.__name__+' ## ')
716 
717  if(mode=='print_v'):
718  print_view+=m.print_JobProperties(mode)
719  else:
720  m.print_JobProperties(mode)
721 
722  if mode=='print_v':
723  return print_view
724  if self._context_name.count('.')==0:
725  self._log.info("### Ends the job properties container %s ###",
726  self.__name__ )
727 

◆ set_JobProperties()

def python.JobProperties.JobPropertyContainer.set_JobProperties (   self,
  data 
)
It can be used to set several job properties in different
    JobContainers in one step.


    The expected data must be a dict as for example:

     data={'JobProperties.SimFlags':{'init_Level':2,'SeedsG4':.98},
   'JobProperties.Digitization':{'writeMuonDigit':False}
  }

Definition at line 728 of file JobProperties.py.

728  def set_JobProperties(self,data):
729  """ It can be used to set several job properties in different
730  JobContainers in one step.
731 
732 
733  The expected data must be a dict as for example:
734 
735  data={'JobProperties.SimFlags':{'init_Level':2,'SeedsG4':.98},
736  'JobProperties.Digitization':{'writeMuonDigit':False}
737  }
738 
739  """
740  tp=type(data)
741  if tp.__name__=='dict':
742  list_context=list(JobProperty._nInstancesContextDict.keys())
743  for i in data.keys():
744  for j in data[i].keys():
745  if list_context.count(i+'.'+j)==1:
746  jp=JobProperty._nInstancesContextDict[i+'.'+j]
747  jp.set_Value(data[i][j])
748  self._log.info("The JobProperty %s has been set to %s",
749  i+'.'+j,data[i][j])
750  else:
751  self._log.warning("The JobProperty %s does not exist",
752  i+'.'+j)
753  else:
754  raise ValueError('The received data is has not the expected'
755  'type/format')
756 

◆ unlock_JobProperties()

def python.JobProperties.JobPropertyContainer.unlock_JobProperties (   self)
Unlocks the Values of the JobProperties

Definition at line 660 of file JobProperties.py.

660  def unlock_JobProperties(self):
661  """ Unlocks the Values of the JobProperties
662  """
663  for j in self.__dict__.keys():
664  j_obj=self.__dict__.get(j)
665  if hasattr(j_obj,'lock_JobProperties'):
666  j_obj.unlock_JobProperties()
667  j_obj._locked=False
668  elif hasattr(j_obj,'_locked'):
669  j_obj._locked=False
670  self._log.warning('The JobProperty Container %s is being unlocked ',
671  self.__name__)
672 

Member Data Documentation

◆ __name__

python.JobProperties.JobPropertyContainer.__name__
private

Definition at line 474 of file JobProperties.py.

◆ _context_name

python.JobProperties.JobPropertyContainer._context_name
private

Definition at line 475 of file JobProperties.py.

◆ _locked

bool python.JobProperties.JobPropertyContainer._locked = False
staticprivate

Definition at line 462 of file JobProperties.py.

◆ _log

python.JobProperties.JobPropertyContainer._log = Logging.logging.getLogger('JobPropertyContainer::')
staticprivate

Definition at line 460 of file JobProperties.py.

◆ _nInstancesContextList

python.JobProperties.JobPropertyContainer._nInstancesContextList = list()
staticprivate

Definition at line 461 of file JobProperties.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.CaloScaleNoiseConfig.help
help
Definition: CaloScaleNoiseConfig.py:76
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:41
error
Definition: IImpactPoint3dEstimator.h:70
python.Bindings.__contains__
__contains__
Definition: Control/AthenaPython/python/Bindings.py:757