12
12
from h2o_wave .core import expando_to_dict
13
13
from sidekick .prompter import db_setup_api , query_api
14
14
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
17
16
18
17
# Load the config file and initialize required paths
19
18
base_path = (Path (__file__ ).parent / "../" ).resolve ()
@@ -407,7 +406,7 @@ async def fileupload(q: Q):
407
406
q .user .table_info_path = usr_info_path
408
407
q .user .sample_qna_path = usr_sample_qa
409
408
410
- db_resp = db_setup_api (
409
+ n_rows , db_resp = db_setup_api (
411
410
db_name = q .user .db_name ,
412
411
hostname = q .user .host_name ,
413
412
user_name = q .user .user_name ,
@@ -418,6 +417,7 @@ async def fileupload(q: Q):
418
417
table_name = q .user .table_name ,
419
418
)
420
419
logging .info (f"DB updates: \n { db_resp } " )
420
+ q .args .n_rows = n_rows
421
421
if "error" in str (db_resp ).lower ():
422
422
q .page ["dataset" ].error_upload_bar .visible = True
423
423
q .page ["dataset" ].error_bar .visible = False
@@ -457,7 +457,12 @@ async def datasets(q: Q):
457
457
text = "Upload failed; something went wrong. Please check the dataset name/column name for special characters and try again!" ,
458
458
visible = False ,
459
459
),
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
+ ),
461
466
ui .file_upload (
462
467
name = "sample_data" ,
463
468
label = "Dataset" ,
@@ -648,7 +653,7 @@ def upload_demo_examples(q: Q):
648
653
q .user .table_info_path = f"{ sample_data_path } /table_info.jsonl"
649
654
q .user .sample_qna_path = None
650
655
651
- db_resp = db_setup_api (
656
+ n_rows , db_resp = db_setup_api (
652
657
db_name = q .user .db_name ,
653
658
hostname = q .user .host_name ,
654
659
user_name = q .user .user_name ,
@@ -660,6 +665,7 @@ def upload_demo_examples(q: Q):
660
665
)
661
666
logging .info (f"DB updated with demo examples: \n { db_resp } " )
662
667
q .args .table_dropdown = usr_table_name
668
+ return n_rows
663
669
664
670
665
671
async def on_event (q : Q ):
@@ -757,7 +763,7 @@ async def on_event(q: Q):
757
763
elif q .args .demo_mode :
758
764
logging .info (f"Switching to demo mode!" )
759
765
# If demo datasets are not present, register them.
760
- upload_demo_examples (q )
766
+ _ = upload_demo_examples (q )
761
767
logging .info (f"Demo dataset selected: { q .user .table_name } " )
762
768
await submit_table (q )
763
769
sample_qs = """
0 commit comments