shlomihod commited on
Commit
3b81a6b
·
1 Parent(s): 44783c4

handle error at startup

Browse files
Files changed (1) hide show
  1. app.py +33 -29
app.py CHANGED
@@ -576,41 +576,45 @@ def combine_labels(labels):
576
 
577
 
578
  def main():
579
- if "dataset_split_seed" not in st.session_state:
580
- st.session_state["dataset_split_seed"] = (
581
- int(DATASET_SPLIT_SEED) if DATASET_SPLIT_SEED else None
582
- )
 
583
 
584
- if "train_size" not in st.session_state:
585
- st.session_state["train_size"] = TRAIN_SIZE
586
 
587
- if "test_size" not in st.session_state:
588
- st.session_state["test_size"] = TEST_SIZE
589
 
590
- if "api_call_function" not in st.session_state:
591
- st.session_state["api_call_function"] = build_api_call_function(
592
- model=HF_MODEL, hf_token=HF_TOKEN
593
- )
594
 
595
- if "train_dataset" not in st.session_state:
596
- (
597
- st.session_state["dataset_name"],
598
- splits_df,
599
- st.session_state["input_columns"],
600
- st.session_state["label_column"],
601
- st.session_state["labels"],
602
- ) = prepare_datasets(
603
- HF_DATASET,
604
- train_size=st.session_state.train_size,
605
- test_size=st.session_state.test_size,
606
- dataset_split_seed=st.session_state.dataset_split_seed,
607
- )
 
 
 
608
 
609
- for split in splits_df:
610
- st.session_state[f"{split}_dataset"] = splits_df[split]
611
 
612
- if "generation_config" not in st.session_state:
613
- st.session_state["generation_config"] = GENERATION_CONFIG_DEFAULTS
614
 
615
  st.title(TITLE)
616
 
 
576
 
577
 
578
  def main():
579
+ try:
580
+ if "dataset_split_seed" not in st.session_state:
581
+ st.session_state["dataset_split_seed"] = (
582
+ int(DATASET_SPLIT_SEED) if DATASET_SPLIT_SEED else None
583
+ )
584
 
585
+ if "train_size" not in st.session_state:
586
+ st.session_state["train_size"] = TRAIN_SIZE
587
 
588
+ if "test_size" not in st.session_state:
589
+ st.session_state["test_size"] = TEST_SIZE
590
 
591
+ if "api_call_function" not in st.session_state:
592
+ st.session_state["api_call_function"] = build_api_call_function(
593
+ model=HF_MODEL, hf_token=HF_TOKEN
594
+ )
595
 
596
+ if "train_dataset" not in st.session_state:
597
+ (
598
+ st.session_state["dataset_name"],
599
+ splits_df,
600
+ st.session_state["input_columns"],
601
+ st.session_state["label_column"],
602
+ st.session_state["labels"],
603
+ ) = prepare_datasets(
604
+ HF_DATASET,
605
+ train_size=st.session_state.train_size,
606
+ test_size=st.session_state.test_size,
607
+ dataset_split_seed=st.session_state.dataset_split_seed,
608
+ )
609
+
610
+ for split in splits_df:
611
+ st.session_state[f"{split}_dataset"] = splits_df[split]
612
 
613
+ if "generation_config" not in st.session_state:
614
+ st.session_state["generation_config"] = GENERATION_CONFIG_DEFAULTS
615
 
616
+ except Exception as e:
617
+ st.error(e)
618
 
619
  st.title(TITLE)
620