Commit 60b99806 authored by Martin Schorb's avatar Martin Schorb
Browse files

performance in all pages

parent b7496b98
......@@ -36,7 +36,7 @@ def init_update_store(thismodule,prevmodule,comp_in='store_render_launch',comp_o
return dash_out,dash_in,dash_state
def update_store(prevstore,thisstore,thispage):
def update_store(prevstore,thisstore):
if not dash.callback_context.triggered:
raise PreventUpdate
......@@ -64,15 +64,12 @@ def update_owner_dd(init_in,thispage,dd_options_in):
if not dash.callback_context.triggered:
raise PreventUpdate
if thispage in (None,''):
raise PreventUpdate
thispage = thispage.lstrip('/')
trigger = hf.trigger()
if thispage=='' or not thispage in hf.trigger(key='module') and not dd_options_in is None:
if thispage in (None,'') or not thispage in hf.trigger(key='module') and not dd_options_in is None:
raise PreventUpdate
dd_options = list(dict())
......
......@@ -8,17 +8,14 @@ Created on Tue Nov 3 13:30:16 2020
from dash import dcc
from dash import html
from dash.dependencies import Input,Output,State
# import os
# import glob
# import numpy as np
# import requests
from dash.exceptions import PreventUpdate
import params
from app import app
from utils import pages
# from utils import helper_functions as hf
from utils import helper_functions as hf
from callbacks import runstate,render_selector,boundingbox,match_selector,tile_view
......@@ -50,7 +47,14 @@ us_out,us_in,us_state = render_selector.init_update_store(module,'solve')
@app.callback(us_out,us_in,us_state,
prevent_initial_call=True)
def export_update_store(*args):
def export_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
return render_selector.update_store(*args)
page1 = pages.render_selector(module)
......
......@@ -77,10 +77,15 @@ page.append(gobutton)
@app.callback([Output(label+'_input_dd', 'options'),
Output(label+'_input_dd', 'value')],
[Input(parent+'_format_dd', 'value'),
Input('url', 'pathname')
])
def finalize_volume_dd(dd_in,url):
Input('url', 'pathname')]
,prevent_initial_call=True)
def finalize_volume_dd(dd_in,thispage):
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
# if not dash.callback_context.triggered:
# raise PreventUpdate
......
......@@ -70,9 +70,16 @@ page.append(compute_settings)
[Output({'component': 'factors', 'module': label},'modified_timestamp')],
[Input({'component': 'input_'+col, 'module': label},'value') for col in compute_table_cols],
[Input({'component': 'factors', 'module': label},'modified_timestamp')],
State({'component': 'factors', 'module': label},'data')
)
[State({'component': 'factors', 'module': label},'data'),
State('url','pathname')]
,prevent_initial_call=True)
def n5export_update_compute_settings(*inputs):
thispage = inputs[-1]
inputs = inputs[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
idx_offset = len(compute_table_cols)
......@@ -147,13 +154,20 @@ stackoutput.extend(compute_tablefields)
State({'component': 'store_project', 'module': parent}, 'data'),
State({'component': 'store_stack', 'module': parent}, 'data'),
State({'component': 'store_allstacks', 'module': parent}, 'data'),
State({'component': "path_input", 'module': label},'value')]
)
State({'component': "path_input", 'module': label},'value'),
State('url','pathname')]
,prevent_initial_call=True)
def n5export_stacktodir(stack_sel,
xmin,xmax,ymin,ymax,zmin,zmax,
browsetrig,
owner,project,stack,allstacks,
browsedir):
browsedir,
thispage):
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
dir_out=''
out=dict()
......
......@@ -80,6 +80,7 @@ us_out,us_in,us_state = render_selector.init_update_store(label,parent,comp_in='
prevent_initial_call=True)
def sbem_conv_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage=='' or not thispage in hf.trigger(key='module'):
......
......@@ -72,6 +72,8 @@ us_out,us_in,us_state = render_selector.init_update_store(label,parent,comp_in='
prevent_initial_call=True)
def tilepairs_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage=='' or not thispage in hf.trigger(key='module'):
......
......@@ -9,6 +9,8 @@ import dash
from dash import dcc
from dash import html
from dash.dependencies import Input,Output,State, MATCH, ALL
from dash.exceptions import PreventUpdate
import json
import requests
......@@ -61,7 +63,14 @@ page = [main]
us_out,us_in,us_state = render_selector.init_update_store(module,'convert')
@app.callback(us_out,us_in,us_state)
def mipmaps_update_store(*args):
def mipmaps_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
return render_selector.update_store(*args)
page1 = pages.render_selector(module)
......@@ -103,9 +112,17 @@ page.append(pages.substack_sel(module,hidden=True))
@app.callback(Output({'component':'store_compset','module':module},'data'),
[Input({'component': 'input_'+col, 'module': module},'value') for col in compute_table_cols],
State('url','pathname'),
prevent_initial_call=True)
def mipmaps_store_compute_settings(*inputs):
def mipmaps_store_compute_settings(*inputs):
thispage = inputs[-1]
inputs = inputs[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
storage=dict()
in_labels,in_values = hf.input_components()
......@@ -137,10 +154,16 @@ stackoutput.extend(compute_tablefields)
[State({'component': 'store_owner', 'module': module}, 'data'),
State({'component': 'store_project', 'module': module}, 'data'),
State({'component': 'store_stack', 'module': module}, 'data'),
State({'component': 'store_allstacks', 'module': module}, 'data')]
)
def mipmaps_stacktodir(stack_sel,owner,project,stack,allstacks):
State({'component': 'store_allstacks', 'module': module}, 'data'),
State('url','pathname')]
,prevent_initial_call=True)
def mipmaps_stacktodir(stack_sel,owner,project,stack,allstacks,thispage):
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
dir_out=''
out=dict()
......
......@@ -10,6 +10,8 @@ import dash
from dash import dcc
from dash import html
from dash.dependencies import Input,Output,State
from dash.exceptions import PreventUpdate
import os
import glob
import numpy as np
......@@ -67,7 +69,14 @@ us_out,us_in,us_state = render_selector.init_update_store(module,'tilepairs')
@app.callback(us_out,us_in,us_state,
prevent_initial_call=True)
def pointmatch_update_store(*args):
def pointmatch_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
return render_selector.update_store(*args)
page1 = pages.render_selector(module)
......@@ -96,11 +105,19 @@ page.append(page2)
@app.callback([Output({'component': 'tp_dd', 'module': module},'options'),
Output({'component': 'tp_dd', 'module': module},'value')],
Input({'component': 'stack_dd', 'module': module},'value'))
def pointmatch_tp_dd_fill(stack):
Input({'component': 'stack_dd', 'module': module},'value'),
State('url','pathname')
,prevent_initial_call=True)
def pointmatch_tp_dd_fill(stack,thispage):
if stack in (None,''):
return dash.no_update
raise PreventUpdate
thispage = thispage.lstrip('/')
if thispage in (None, '') or not thispage in hf.trigger(key='module') and not dd_options_in is None:
raise PreventUpdate
tp_dirlist = [d_item for d_item in glob.glob(params.json_run_dir+'/tilepairs_'+params.user+'*'+stack+'*') if os.path.isdir(d_item)]
tpdir_dd_options=list(dict())
......@@ -110,13 +127,10 @@ def pointmatch_tp_dd_fill(stack):
else:
for tp_dir in tp_dirlist:
tpdir_dd_options.append({'label':os.path.basename(tp_dir), 'value':tp_dir})
return tpdir_dd_options,tpdir_dd_options[-1]['value']
# ===============================================
......@@ -127,7 +141,6 @@ page.append(page3)
# # ===============================================
# Compute Settings
......@@ -150,10 +163,19 @@ compute_settings = html.Details(children=[html.Summary('Compute settings:'),
[Output({'component': 'factors', 'module': module},'modified_timestamp')],
[Input({'component': 'input_'+col, 'module': module},'value') for col in compute_table_cols],
[Input({'component': 'factors', 'module': module},'modified_timestamp')],
State({'component': 'factors', 'module': module},'data')
)
[State({'component': 'factors', 'module': module},'data'),
State('url','pathname')]
,prevent_initial_call=True)
def pointmatch_update_compute_settings(*inputs):
thispage = inputs[-1]
inputs = inputs[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
idx_offset = len(compute_table_cols)
trigger = hf.trigger()
......@@ -215,16 +237,19 @@ stackoutput.extend(compute_tablefields)
Input({'component': 'store_tpmatchtime', 'module': module}, 'data'),
Input({'component': 'input_Num_CPUs', 'module': module},'value')],
[State({'component': 'stack_dd', 'module': module},'value'),
State({'component': 'store_owner', 'module': module}, 'data'),
State({'component': 'store_project', 'module': module}, 'data'),
State({'component': 'store_stack', 'module': module}, 'data'),
State({'component': 'store_allstacks', 'module': module}, 'data')]
)
def pointmatch_comp_set(tilepairdir,matchtime,n_cpu,stack_sel,owner,project,stack,allstacks):
State({'component': 'store_allstacks', 'module': module}, 'data'),
State('url','pathname')]
, prevent_initial_call=True)
def pointmatch_comp_set(tilepairdir,matchtime,n_cpu,stack_sel,allstacks,thispage):
if n_cpu is None:
n_cpu = params.n_cpu_spark
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
n_cpu = int(n_cpu)
out=dict()
......
......@@ -90,8 +90,14 @@ page.append(gobutton)
@app.callback([Output(label+'organism_dd','options'),
Output(label+'picks','data')],
[Input({'component': 'tp_dd', 'module': parent},'value')],
)
def sift_pointmatch_organisms(tilepairdir):
State('url','pathname')
, prevent_initial_call=True)
def sift_pointmatch_organisms(tilepairdir,thispage):
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
mT_jsonfiles = glob.glob(os.path.join(params.json_match_dir,'*.json'))
organisms=list()
......@@ -142,9 +148,9 @@ def sift_pointmatch_IDs(organism,picks):
@app.callback([Output(label+'mt_link','href'),
Output(label+'mtselect','value')],
Input(label+'matchID_dd','value'),
Input(label+'matchID_dd','value')
# State(label+'picks','data'),
)
, prevent_initial_call=True)
def sift_browse_matchTrial(matchID):
if matchID is None:
return dash.no_update
......@@ -179,9 +185,15 @@ def sift_browse_matchTrial(matchID):
State({'component':'store_project','module' : parent},'data'),
State({'component':'stack_dd','module' : parent},'value'),
State({'component': 'input_Num_CPUs', 'module': parent},'value'),
State({'component': 'input_runtime_minutes', 'module': parent},'value')]
State({'component': 'input_runtime_minutes', 'module': parent},'value'),
State('url','pathname')]
,prevent_initial_call=True)
def sift_pointmatch_execute_gobutton(click,matchID,matchcoll,comp_sel,mc_owner,tilepairdir,owner,project,stack,n_cpu,timelim):
def sift_pointmatch_execute_gobutton(click,matchID,matchcoll,comp_sel,mc_owner,tilepairdir,owner,project,stack,n_cpu,timelim,thispage):
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
ctx = dash.callback_context
trigger = ctx.triggered[0]['prop_id']
......
......@@ -59,6 +59,13 @@ us_out,us_in,us_state = render_selector.init_update_store(module,'pointmatch')
@app.callback(us_out,us_in,us_state,
prevent_initial_call=True)
def solve_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage == '' or not thispage in hf.trigger(key='module'):
raise PreventUpdate
return render_selector.update_store(*args)
page1 = pages.render_selector(module)
......@@ -134,8 +141,16 @@ page.append(stack_div)
[Input({'component': 'stack_dd', 'module': module}, 'options'),
Input(module+'stack_input', 'value')],
[State({'component': 'owner_dd', 'module': module}, 'value'),
State({'component': 'project_dd', 'module': module}, 'value')])
def solve_stacks(dd_options_in,newstack_name,owner,project_sel):
State({'component': 'project_dd', 'module': module}, 'value'),
State('url','pathname')]
,prevent_initial_call=True)
def solve_stacks(dd_options_in,newstack_name,owner,project_sel,thispage):
thispage = thispage.lstrip('/')
if thispage in (None, '') or not thispage in hf.trigger(key='module') and not dd_options_in is None:
raise PreventUpdate
ctx = dash.callback_context
trigger = ctx.triggered[0]['prop_id'].split('.')[0].partition(module)[2]
stack = 'newstack'
......@@ -165,10 +180,18 @@ def solve_stacks(dd_options_in,newstack_name,owner,project_sel):
Output(module+'browse_stackdiv','style')],
Input({'component':'outstack_dd','module' : module},'value'),
[State({'component': 'project_dd', 'module': module}, 'value'),
State({'component': 'owner_dd', 'module': module}, 'value')])
def solve_update_stack_browse(stack_state,project_sel,owner):
State({'component': 'owner_dd', 'module': module}, 'value'),
State('url','pathname')]
,prevent_initial_call=True)
def solve_update_stack_browse(stack_state,project_sel,owner,thispage):
thispage = thispage.lstrip('/')
if thispage in (None, '') or not thispage in hf.trigger(key='module') and not dd_options_in is None:
raise PreventUpdate
if project_sel is None or owner is None or stack_state is None:
return dash.no_update
raise PreventUpdate
if stack_state == 'newstack':
return params.render_base_url, {'display':'none'}
......@@ -179,7 +202,8 @@ def solve_update_stack_browse(stack_state,project_sel,owner):
# Create a new Stack
@app.callback(Output(module+'newstack','style'),
Input({'component':'outstack_dd','module' : module},'value'))
Input({'component':'outstack_dd','module' : module},'value')
,prevent_initial_call=True)
def solve_new_stack_input(stack_value):
if stack_value=='newstack':
style={'display':'block'}
......@@ -254,7 +278,7 @@ page.append(gobutton)
State({'component':'store_project','module' : module},'data'),
State({'component':'stack_dd','module' : module},'value'),
State({'component':'mc_owner_dd','module':module},'value')]
)
,prevent_initial_call=True)
def solve_execute_gobutton(click,matchcoll,outstack,tform,stype,comp_sel,startsection,endsection,owner,project,stack,mc_own):
if not dash.callback_context.triggered:
raise PreventUpdate
......
......@@ -52,6 +52,7 @@ us_out,us_in,us_state = render_selector.init_update_store(module,'convert')
prevent_initial_call=True)
def tilepairs_update_store(*args):
thispage = args[-1]
args = args[:-1]
thispage = thispage.lstrip('/')
if thispage=='' or not thispage in hf.trigger(key='module'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment