From e7cf8a87cd44de097b9df05b5a12f240af144374 Mon Sep 17 00:00:00 2001 From: Chris Nivera Date: Wed, 16 Oct 2024 11:52:22 -0700 Subject: [PATCH] catch empty name and tables --- app_utils/shared_utils.py | 4 ++-- journeys/builder.py | 19 +++++++++++-------- partner/looker.py | 16 ++++++++++------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app_utils/shared_utils.py b/app_utils/shared_utils.py index 4d29d72b..fd3425b8 100644 --- a/app_utils/shared_utils.py +++ b/app_utils/shared_utils.py @@ -1223,9 +1223,9 @@ def run_generate_model_str_from_snowflake( """ if not model_name: - st.error("Please provide a name for your semantic model.") + raise ValueError("Please provide a name for your semantic model.") elif not base_tables: - st.error("Please select at least one table to proceed.") + raise ValueError("Please select at least one table to proceed.") else: with st.spinner("Generating model. This may take a minute or two..."): yaml_str = generate_model_str_from_snowflake( diff --git a/journeys/builder.py b/journeys/builder.py index a6ca0864..857fd33d 100644 --- a/journeys/builder.py +++ b/journeys/builder.py @@ -125,14 +125,17 @@ def table_selector_dialog() -> None: submit = st.button("Submit", use_container_width=True, type="primary") if submit: - run_generate_model_str_from_snowflake( - model_name, - sample_values, - st.session_state["selected_tables"], - allow_joins=experimental_features, - ) - st.session_state["page"] = GeneratorAppScreen.ITERATION - st.rerun() + try: + run_generate_model_str_from_snowflake( + model_name, + sample_values, + st.session_state["selected_tables"], + allow_joins=experimental_features, + ) + st.session_state["page"] = GeneratorAppScreen.ITERATION + st.rerun() + except ValueError as e: + st.error(e) def show() -> None: diff --git a/partner/looker.py b/partner/looker.py index 1483eff9..903a62e1 100644 --- a/partner/looker.py +++ b/partner/looker.py @@ -272,12 +272,16 @@ def set_looker_semantic() -> None: if st.session_state[ "looker_field_metadata" ]: # Create view only if full rendering is successful - run_generate_model_str_from_snowflake( - model_name, - sample_values, - [full_tablename], - allow_joins=experimental_features, - ) + try: + run_generate_model_str_from_snowflake( + model_name, + sample_values, + [full_tablename], + allow_joins=experimental_features, + ) + except ValueError as e: + st.error(e) + st.stop() st.session_state["partner_setup"] = True # Tag looker setup with SIT query tag