async def serve(q: Q): if q.args.show_inputs: q.page['example'].items = [ ui.text(f'spinbox={q.args.spinbox}'), ui.text(f'spinbox_disabled={q.args.spinbox_disabled}'), ui.button(name='show_form', label='Back', primary=True), ] else: q.page['example'] = ui.form_card( box='1 1 4 10', items=[ ui.spinbox(name='spinbox', label='Standard spinbox', min=0, max=100, step=10, value=30), ui.spinbox(name='spinbox_disabled', label='Disabled spinbox', min=0, max=100, step=10, value=30, disabled=True), ui.button(name='show_inputs', label='Submit', primary=True), ]) await q.page.save()
async def serve(q: Q): q.page['example'] = ui.form_card(box='1 1 4 10', items=[ ui.text_xl(content='Extra-large text, for headings.'), ui.text_l(content='Large text, for sub-headings.'), ui.text_m(content='Body text, for paragraphs and other content.'), ui.text_s(content='Small text, for small print.'), ui.text_xs(content='Extra-small text, for really small print.'), ui.separator(label='A separator sections forms'), ui.progress(label='A progress bar'), ui.progress(label='A progress bar'), ui.message_bar(type='success', text='Message bar'), ui.textbox(name='textbox', label='Textbox'), ui.label(label='Checkboxes'), ui.checkbox(name='checkbox1', label='A checkbox'), ui.checkbox(name='checkbox1', label='Another checkbox'), ui.checkbox(name='checkbox1', label='Yet another checkbox'), ui.toggle(name='toggle', label='Toggle'), ui.choice_group(name='choice_group', label='Choice group', choices=[ ui.choice(name=x, label=x) for x in ['Egg', 'Bacon', 'Spam'] ]), ui.checklist(name='checklist', label='Checklist', choices=[ ui.choice(name=x, label=x) for x in ['Egg', 'Bacon', 'Spam'] ]), ui.dropdown(name='dropdown', label='Dropdown', choices=[ ui.choice(name=x, label=x) for x in ['Egg', 'Bacon', 'Spam'] ]), ui.dropdown(name='dropdown', label='Multi-valued Dropdown', values=[], choices=[ ui.choice(name=x, label=x) for x in ['Egg', 'Bacon', 'Spam'] ]), ui.combobox(name='combobox', label='Combobox', choices=['Choice 1', 'Choice 2', 'Choice 3']), ui.slider(name='slider', label='Slider'), ui.range_slider(name='range_slider', label='Range slider', max=99), ui.spinbox(name='spinbox', label='Spinbox'), ui.date_picker(name='date_picker', label='Date picker'), ui.color_picker(name='color_picker', label='Color picker'), ui.buttons([ ui.button(name='primary_button', label='Primary', primary=True), ui.button(name='standard_button', label='Standard'), ui.button(name='standard_disabled_button', label='Standard', disabled=True), ]), ui.file_upload(name='file_upload', label='File upload'), ui.table(name='table', columns=[ ui.table_column(name='col1', label='Column 1'), ui.table_column(name='col2', label='Column 2'), ], rows=[ ui.table_row(name='row1', cells=['Text A', 'Text B']), ui.table_row(name='row2', cells=['Text C', 'Text D']), ui.table_row(name='row3', cells=['Text E', 'Text F']), ]), ui.link(label='Link'), ui.tabs(name='tabs', items=[ ui.tab(name='email', label='Mail', icon='Mail'), ui.tab(name='events', label='Events', icon='Calendar'), ui.tab(name='spam', label='Spam'), ]), ui.expander(name='expander', label='Expander'), ui.frame(path='https://example.com'), ui.markup(content=html), ui.template( content=menu, data=pack(dict(dishes=[ dict(name='Spam', price='$2.00'), dict(name='Ham', price='$3.45'), dict(name='Eggs', price='$1.75'), ])) ), ui.picker(name='picker', label='Picker', choices=[ ui.choice('choice1', label='Choice 1'), ui.choice('choice2', label='Choice 2'), ui.choice('choice3', label='Choice 3'), ]), ui.stepper(name='stepper', items=[ ui.step(label='Step 1', icon='MailLowImportance'), ui.step(label='Step 2', icon='TaskManagerMirrored'), ui.step(label='Step 3', icon='Cafe'), ]), ui.visualization( plot=ui.plot([ui.mark(type='interval', x='=product', y='=price', y_min=0)]), data=data(fields='product price', rows=[(c, x) for c, x, _ in [f.next() for _ in range(n)]], pack=True), ), ui.vega_visualization( specification=spec, data=data(fields=["a", "b"], rows=[ ["A", rnd()], ["B", rnd()], ["C", rnd()], ["D", rnd()], ["E", rnd()], ["F", rnd()], ["G", rnd()], ["H", rnd()], ["I", rnd()] ], pack=True), ), ui.button(name='show_inputs', label='Submit', primary=True), ]) await q.page.save()
async def serve(q: Q): if q.args.train: # train WaveML Model using H2O-3 AutoML copy_expando(q.args, q.client) exclude_algos = [] if q.client.include_dl else ['DeepLearning'] q.client.wave_model = build_model( train_df=q.client.train_df, target_column='target', model_type=ModelType.H2O3, _h2o3_max_runtime_secs=q.client.max_runtime_secs, _h2o3_nfolds=2, _h2o3_exclude_algos=exclude_algos) model_id = q.client.wave_model.model.model_id accuracy = round( 100 - q.client.wave_model.model.mean_per_class_error() * 100, 2) # show training details and prediction option q.page['example'].items[1].spinbox.value = q.client.max_runtime_secs q.page['example'].items[2].toggle.value = q.client.include_dl q.page['example'].items[3].buttons.items[1].button.disabled = False q.page['example'].items[4].message_bar.type = 'success' q.page['example'].items[ 4].message_bar.text = 'Training successfully completed!' q.page['example'].items[ 5].text.content = f'''**H2O AutoML model id:** {model_id} <br /> **Accuracy:** {accuracy}%''' q.page['example'].items[6].text.content = '' elif q.args.predict: # predict on test data preds = q.client.wave_model.predict(test_df=q.client.test_df) # show predictions q.page['example'].items[ 4].message_bar.text = 'Prediction successfully completed!' q.page['example'].items[ 6].text.content = f'''**Example predictions:** <br /> {preds[0]} <br /> {preds[1]} <br /> {preds[2]}''' else: # prepare sample train and test dataframes data = load_wine(as_frame=True)['frame'] q.client.train_df, q.client.test_df = train_test_split(data, train_size=0.8) # display ui q.page['example'] = ui.form_card( box='1 1 -1 -1', items=[ ui.text(content='''The sample dataset used is the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_wine.html" target="_blank">wine dataset</a>.''' ), ui.spinbox(name='max_runtime_secs', label='Max Runtime (Secs)', min=5, max=30, step=1, value=10), ui.toggle(name='include_dl', label='Include Deep Learning', value=False), ui.buttons(items=[ ui.button(name='train', label='Train', primary=True), ui.button(name='predict', label='Predict', primary=True, disabled=True), ]), ui.message_bar(type='warning', text='Training will take a few seconds'), ui.text(content=''), ui.text(content='') ]) await q.page.save()
def get_form_items(value: Optional[float]): return [ ui.text(f'spinbox_trigger={value}'), ui.spinbox(name='spinbox_trigger', label='Pick a number', trigger=True), ]