Package Ganga :: Package GPIDev :: Package Adapters :: Module IApplication
[hide private]
[frames] | no frames]

Source Code for Module Ganga.GPIDev.Adapters.IApplication

  1  ################################################################################ 
  2  # Ganga Project. http://cern.ch/ganga 
  3  # 
  4  # $Id: IApplication.py,v 1.1 2008-07-17 16:40:52 moscicki Exp $ 
  5  ################################################################################ 
  6   
  7  from Ganga.GPIDev.Base import GangaObject 
  8  from Ganga.GPIDev.Schema import * 
  9   
 10  import Ganga.Utility.logging 
 11  logger = Ganga.Utility.logging.getLogger() 
 12   
 13   
14 -class PostprocessStatusUpdate(Exception):
15 """ This exception may be raised by postprocess hooks to change the job status."""
16 - def __init__(self,status):
17 Exception.__init__(self) 18 self.status = status
19 20
21 -class IApplication(GangaObject):
22 23 """ 24 Base class for all application objects. Derived classes represent 25 logical applications in the GPI and implement configuration 26 handler functionality. The application configuration is the first 27 phase of job submission. 28 29 General rules for implementing the configure methods: 30 31 In general the configure() and master_configure() methods are 32 called always in the context of job submission, so in principle 33 you may navigate to the associated job object (including backend 34 information). However it is not advised to use backend or extra 35 sandbox information at this point. Code which depends on the 36 backend should be put in application-specific runtime handler 37 which is the next step of job submission. 38 39 The input/output dataset information may be used if neccessary. 40 Objects in the job object tree should not be modified. 41 42 Efficient implementation of splitting: 43 44 If you want to enable the typical case of splitting based on the 45 dataset (defined at the job level) then it is very simple: 46 configure() should only process the inputdata part of the job 47 configuration and master_configure() should do the rest. In that 48 case the splitter should not mutate the application object in the 49 subjobs, because such changes will not be taken into account (and 50 framework will have inconsistent behaviour). 51 52 You may also take an extreme approach and move the entire 53 application configuration to configure(). Arbitrary 54 modifications of the application object in the subjobs which are 55 done by the splitter will take effect. But if the application 56 configuration process is time consuming it will be repeated a 57 number of times which is inneficient. 58 59 Otherwise you should first identify which parts of the 60 application object may be altered by the splitter and process 61 them in configure() method. The master_configure() should 62 perform only the time-consuming part of the configuration which 63 is shared among the subjobs. This means that splitter should not 64 try to modify the application parameters which are used in the 65 common master_configure(). """ 66 67 _schema = Schema(Version(0,0), {}) 68 _category='applications' 69 _hidden = 1 70
71 - def master_configure(self):
72 73 """ Configure the shared/master aspect of the application. 74 Return a tuple (modified_flag, appconfig). 75 76 This method is always called exactly once, also in the case of 77 splitting. 78 79 Return tuple: 80 81 - appconfig (also known as appextra) is an arbitrary 82 structure which will be processed by application-specific 83 runtime handler as the next step of job submission. 84 85 - modified_flag is True if application object (self) has 86 been modified during configure() 87 88 If this method is not implemented in the derived class then it 89 is ignored. """ 90 91 return (0,None)
92 93
94 - def configure(self,master_appconfig):
95 96 """ Configure the specific aspect of the application . This 97 method has a similar meaning as master_configure() method and 98 it should return a tuple (modified_flag,appconfig). 99 100 This method must be implemented in a derived class. Otherwise 101 the submission will fail. 102 103 Arguments: 104 - master_appconfig is a result of the master job master_configure() 105 method. 106 107 In case of splitting this method will be called for each 108 subjob object exactly once which means that it will be 109 executed as many times as there are subjobs. 110 111 If there is no splitting this method will be called exactly 112 once, after master_configure(). 113 114 Transition from Ganga 4.0.x: 115 - master_appconfig should be ignored (it is None anyway) 116 """ 117 118 raise NotImplementedError
119
120 - def postprocess(self):
121 """ Postprocessing after the job was reported as completed. By default do nothing. 122 This method may raise an exception PostprocessStatusUpdate('failed'). In this 123 case the job status will be 'failed'. The postprocess_failed() hook will NOT be called.""" 124 pass
125
126 - def postprocess_failed(self):
127 """ Postprocessing after the job was reported as failed. By default do nothing.""" 128 pass
129
130 - def transition_update(self,new_status):
131 """ 132 This method will be called just before the status of the parent Job changes to new_status. 133 The default it to do nothing. 134 """ 135 pass
136