Пример #1
0
def element_list_from_func(func):
    """ TODO: Deprecate """
    arg_name_and_dflt = extract_name_and_default(func)
    elements = list()
    elements.append(hc.H3(func.__name__))
    for d in arg_name_and_dflt:
        elements.append(component_for_arg_spec(d, id_prefix=f"{func.__name__}"))
    return elements
Пример #2
0
def div_list_from_func(func):
    arg_name_and_dflt = extract_name_and_default(func)

    div_list = list()
    div_list.append(html.H3(func.__name__))
    for d in arg_name_and_dflt:
        div_list.append(html.Label(d['name']))
        if d['default'] is not None:
            value = d['default']
            if isinstance(value,
                          bool) or not isinstance(value, (int, float, str)):
                value = str(value)
        else:
            value = ''

        div_list.append(
            dcc.Input(id=d['name'],
                      value=value,
                      type=input_type_from_signature(d)))
    return div_list
Пример #3
0
from py2dash.component_makers import div_list_from_func
from py2dash.component_makers import dropdown_from_list

from otolite.skdash.controller import Controller, estimators
from otolite.skdash.controller import run_model
from py2dash.util import extract_name_and_default, SignatureExtractor

from py2dash.util import Ids

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

extract_signature = SignatureExtractor(attrs=('name', 'default', 'annotation'))

undefined = extract_name_and_default(dcc.Input)[0]['default']

func = run_model

div_list = div_list_from_func(func)
if func == run_model:
    div_list.extend([
        hc.Button(id='submit-button', n_clicks=0, children='Submit'),
        hc.Div(id='output-state')])

ids = Ids()

app.layout = hc.Div([
    hc.Div([
        hc.Label('Learner Kind'),
        dropdown_from_list(Controller.list_learner_kinds(), id=ids.learner_kind)]),