Skip to content

Commit e3ccf54

Browse files
Inform user about the number of rows inserted #44
1 parent 3b313be commit e3ccf54

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ui/app.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from h2o_wave.core import expando_to_dict
1313
from sidekick.prompter import db_setup_api, query_api
1414
from sidekick.query import SQLGenerator
15-
from sidekick.utils import (TASK_CHOICE, get_table_keys, save_query, setup_dir,
16-
update_tables)
15+
from sidekick.utils import TASK_CHOICE, get_table_keys, save_query, setup_dir, update_tables
1716

1817
# Load the config file and initialize required paths
1918
base_path = (Path(__file__).parent / "../").resolve()
@@ -407,7 +406,7 @@ async def fileupload(q: Q):
407406
q.user.table_info_path = usr_info_path
408407
q.user.sample_qna_path = usr_sample_qa
409408

410-
db_resp = db_setup_api(
409+
n_rows, db_resp = db_setup_api(
411410
db_name=q.user.db_name,
412411
hostname=q.user.host_name,
413412
user_name=q.user.user_name,
@@ -418,6 +417,7 @@ async def fileupload(q: Q):
418417
table_name=q.user.table_name,
419418
)
420419
logging.info(f"DB updates: \n {db_resp}")
420+
q.args.n_rows = n_rows
421421
if "error" in str(db_resp).lower():
422422
q.page["dataset"].error_upload_bar.visible = True
423423
q.page["dataset"].error_bar.visible = False
@@ -457,7 +457,12 @@ async def datasets(q: Q):
457457
text="Upload failed; something went wrong. Please check the dataset name/column name for special characters and try again!",
458458
visible=False,
459459
),
460-
ui.message_bar(name="success_bar", type="success", text="Files Uploaded Successfully!", visible=False),
460+
ui.message_bar(
461+
name="success_bar",
462+
type="success",
463+
text=f"Data successfully uploaded, it has {q.args.n_rows} rows!",
464+
visible=False,
465+
),
461466
ui.file_upload(
462467
name="sample_data",
463468
label="Dataset",
@@ -648,7 +653,7 @@ def upload_demo_examples(q: Q):
648653
q.user.table_info_path = f"{sample_data_path}/table_info.jsonl"
649654
q.user.sample_qna_path = None
650655

651-
db_resp = db_setup_api(
656+
n_rows, db_resp = db_setup_api(
652657
db_name=q.user.db_name,
653658
hostname=q.user.host_name,
654659
user_name=q.user.user_name,
@@ -660,6 +665,7 @@ def upload_demo_examples(q: Q):
660665
)
661666
logging.info(f"DB updated with demo examples: \n {db_resp}")
662667
q.args.table_dropdown = usr_table_name
668+
return n_rows
663669

664670

665671
async def on_event(q: Q):
@@ -757,7 +763,7 @@ async def on_event(q: Q):
757763
elif q.args.demo_mode:
758764
logging.info(f"Switching to demo mode!")
759765
# If demo datasets are not present, register them.
760-
upload_demo_examples(q)
766+
_ = upload_demo_examples(q)
761767
logging.info(f"Demo dataset selected: {q.user.table_name}")
762768
await submit_table(q)
763769
sample_qs = """

0 commit comments

Comments
 (0)