#NEWLINE# @ blueprint . route ( '/index.json' , methods = [ 'GET' ] ) #NEWLINE# @ blueprint . route ( '/' , methods = [ 'GET' ] ) #NEWLINE# def home( ) : #NEWLINE# #INDENT# '\n    DIGITS home page\n    Returns information about each job on the server\n\n    Returns JSON when requested:\n        {\n            datasets: [{id, name, status},...],\n            models: [{id, name, status},...]\n        }\n    ' #NEWLINE# running_datasets = get_job_list ( dataset . DatasetJob , True ) #NEWLINE# completed_datasets = get_job_list ( dataset . DatasetJob , False ) #NEWLINE# running_models = get_job_list ( model . ModelJob , True ) #NEWLINE# completed_models = get_job_list ( model . ModelJob , False ) #NEWLINE# if request_wants_json ( ) : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# 'version' : digits . __version__ , #NEWLINE# 'jobs_dir' : config_value ( 'jobs_dir' ) , #NEWLINE# 'datasets' : [ j . json_dict ( ) for j in ( running_datasets + completed_datasets ) ] , #NEWLINE# 'models' : [ j . json_dict ( ) for j in ( running_models + j ) ] , #NEWLINE# #UNINDENT# } #NEWLINE# if config_value ( 'server_name' ) : #NEWLINE# #INDENT# data [ 'server_name' ] = config_value ( 'server_name' ) #NEWLINE# #UNINDENT# return flask . jsonify ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_dataset_options = [ ( 'Images' , [ { #NEWLINE# #INDENT# 'title' : 'Classification' , #NEWLINE# 'id' : 'image-classification' , #NEWLINE# 'url' : flask . url_for ( 'digits.dataset.images.classification.views.new' ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'title' : 'Other' , #NEWLINE# 'id' : 'image-generic' , #NEWLINE# 'url' : flask . url_for ( 'digits.dataset.images.generic.views.new' ) , #NEWLINE# #UNINDENT# } ] ) ] #NEWLINE# new_model_options = [ ( 'Images' , [ { #NEWLINE# #INDENT# 'title' : 'Classification' , #NEWLINE# 'id' : 'image-classification' , #NEWLINE# 'url' : flask . url_for ( 'digits.model.images.classification.views.new' ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'title' : 'Other' , #NEWLINE# 'id' : 'image-generic' , #NEWLINE# 'url' : flask . url_for ( 'digits.model.images.generic.views.new' ) , #NEWLINE# #UNINDENT# } ] ) ] #NEWLINE# return flask . render_template ( 'home.html' , new_dataset_options = new_dataset_options , running_datasets = running_datasets , completed_datasets = completed_datasets , new_model_options = new_model_options , running_models = running_models , completed_models = completed_models , total_gpu_count = len ( scheduler . resources [ 'gpus' ] ) , remaining_gpu_count = sum ( ( r . remaining ( ) for r in scheduler . resources [ 'gpus' ] ) ) )