#NEWLINE# @ blueprint . route ( '/customize' , methods = [ 'POST' ] ) #NEWLINE# def customize( ) : #NEWLINE# #INDENT# '\n    Returns a customized file for the ModelJob based on completed form fields\n    ' #NEWLINE# network = flask . request . args [ 'network' ] #NEWLINE# framework = flask . request . args . get ( 'framework' ) #NEWLINE# if ( not network ) : #NEWLINE# #INDENT# raise werkzeug . exceptions . BadRequest ( 'network not provided' ) #NEWLINE# #UNINDENT# fw = frameworks . get_framework_by_id ( framework ) #NEWLINE# network_desc = fw . get_standard_network_desc ( network ) #NEWLINE# if network_desc : #NEWLINE# #INDENT# return json . dumps ( { #NEWLINE# #INDENT# 'network' : network_desc , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# job = scheduler . get_job ( network ) #NEWLINE# if ( job is None ) : #NEWLINE# #INDENT# raise werkzeug . exceptions . NotFound ( 'Job not found' ) #NEWLINE# #UNINDENT# snapshot = None #NEWLINE# epoch = float ( flask . request . form . get ( 'snapshot_epoch' , 0 ) ) #NEWLINE# if ( epoch == 0 ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( epoch == ( - 1 ) ) : #NEWLINE# #INDENT# snapshot = job . train_task ( ) . pretrained_model #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for ( filename , e ) in job . train_task ( ) . snapshots : #NEWLINE# #INDENT# if ( e == epoch ) : #NEWLINE# #INDENT# snapshot = job . path ( filename ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return json . dumps ( { #NEWLINE# #INDENT# 'network' : job . train_task ( ) . get_network_desc ( ) , #NEWLINE# 'snapshot' : snapshot , #NEWLINE# #UNINDENT# } )