<s> from os . path import join as pjoin <EOL> from . utils import save_dict_to_json_file , load_dict_from_json_file <EOL> class Status ( object ) : <EOL> def __init__ ( self , trainer = None , starting_epoch = <NUM_LIT:0> , starting_update = <NUM_LIT:0> ) : <EOL> self . current_epoch = starting_epoch <EOL> self . current_update = starting_update <EOL> self . current_update_in_epoch = <NUM_LIT:1> <EOL> self . trainer = trainer <EOL> self . training_time = <NUM_LIT:0> <EOL> self . done = False <EOL> self . extra = { } <EOL> def increment_update ( self ) : <EOL> self . current_update += <NUM_LIT:1> <EOL> self . current_update_in_epoch += <NUM_LIT:1> <EOL> def increment_epoch ( self ) : <EOL> self . current_epoch += <NUM_LIT:1> <EOL> self . current_update_in_epoch = <NUM_LIT:0> <EOL> def __repr__ ( self ) : <EOL> return ( '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' ) . format ( self . current_epoch , self . current_update , self . current_update_in_epoch , <EOL> self . trainer , self . training_time , self . done , self . extra ) <EOL> def save ( self , savedir = "<STR_LIT>" ) : <EOL> state = { "<STR_LIT:version>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : self . current_epoch , <EOL> "<STR_LIT>" : self . current_update , <EOL> "<STR_LIT>" : self . current_update_in_epoch , <EOL> "<STR_LIT>" : self . training_time , <EOL> "<STR_LIT>" : self . done , <EOL> "<STR_LIT>" : self . extra , <EOL> } <EOL> save_dict_to_json_file ( pjoin ( savedir , '<STR_LIT>' ) , state ) <EOL> def load ( self , loaddir = "<STR_LIT>" ) : <EOL> state = load_dict_from_json_file ( pjoin ( loaddir , '<STR_LIT>' ) ) <EOL> self . current_epoch = state [ "<STR_LIT>" ] <EOL> self . current_update = state [ "<STR_LIT>" ] <EOL> self . current_update_in_epoch = state [ "<STR_LIT>" ] <EOL> self . training_time = state [ "<STR_LIT>" ] <EOL> self . done = state [ "<STR_LIT>" ] <EOL> self . extra = state [ "<STR_LIT>" ] </s>
