#NEWLINE# @ classmethod #NEWLINE# def from_request( cls , request ) : #NEWLINE# #INDENT# 'Create new TransientShardState from webapp request.' #NEWLINE# mapreduce_spec = MapreduceSpec . from_json_str ( request . get ( 'mapreduce_spec' ) ) #NEWLINE# mapper_spec = mapreduce_spec . mapper #NEWLINE# input_reader_spec_dict = json . loads ( request . get ( 'input_reader_state' ) , cls = JsonDecoder ) #NEWLINE# input_reader = mapper_spec . input_reader_class ( ) . from_json ( input_reader_spec_dict ) #NEWLINE# initial_input_reader_spec_dict = json . loads ( request . get ( 'initial_input_reader_state' ) , cls = JsonDecoder ) #NEWLINE# initial_input_reader = mapper_spec . input_reader_class ( ) . from_json ( initial_input_reader_spec_dict ) #NEWLINE# output_writer = None #NEWLINE# if mapper_spec . output_writer_class ( ) : #NEWLINE# #INDENT# output_writer = mapper_spec . output_writer_class ( ) . from_json ( json . loads ( request . get ( 'output_writer_state' , '{}' ) , cls = JsonDecoder ) ) #NEWLINE# assert isinstance ( output_writer , mapper_spec . output_writer_class ( ) ) , ( '%s.from_json returned an instance of wrong class: %s' % ( mapper_spec . output_writer_class ( ) , cls . __class__ ) ) #NEWLINE# #UNINDENT# request_path = request . path #NEWLINE# base_path = request_path [ : request_path . rfind ( '/' ) ] #NEWLINE# handler = util . try_deserialize_handler ( request . get ( 'serialized_handler' ) ) #NEWLINE# if ( not handler ) : #NEWLINE# #INDENT# handler = mapreduce_spec . mapper . handler #NEWLINE# #UNINDENT# return cls ( base_path , mapreduce_spec , str ( request . get ( 'shard_id' ) ) , int ( request . get ( 'slice_id' ) ) , input_reader , initial_input_reader , output_writer = output_writer , retries = int ( request . get ( 'retries' ) ) , handler = handler )