<s> class Action ( object ) : <EOL> def backward ( self ) : <EOL> raise NotImplementedError ( ) <EOL> def forward ( self ) : <EOL> raise NotImplementedError ( ) <EOL> class Pipeline ( object ) : <EOL> def __init__ ( self , actions ) : <EOL> self . actions = actions <EOL> def execute ( self , ** kwargs ) : <EOL> try : <EOL> for action in self . actions : <EOL> action . forward ( ** kwargs ) <EOL> except : <EOL> self . rollback ( action , ** kwargs ) <EOL> def rollback ( self , action , ** kwargs ) : <EOL> index = self . actions . index ( action ) - <NUM_LIT:1> <EOL> while index >= <NUM_LIT:0> : <EOL> action = self . actions [ index ] <EOL> action . backward ( ** kwargs ) <EOL> index = index - <NUM_LIT:1> </s>
