Skip to content

Commit

Permalink
Reset session in session_state if lost
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jsummer committed Oct 25, 2024
1 parent c3d0477 commit c5ed4bf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app_utils/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,9 @@ def upload_yaml(file_name: str) -> None:
with open(tmp_file_path, "w", encoding='utf-8') as temp_file:
temp_file.write(yaml)

if 'session' not in st.session_state:
set_snowpark_session(get_snowflake_connection())

st.session_state.session.file.put(
tmp_file_path,
f"@{st.session_state.snowflake_stage.stage_name}",
Expand Down Expand Up @@ -1050,6 +1053,9 @@ def download_yaml(file_name: str, stage_name: str) -> str:
import os
import tempfile

if 'session' not in st.session_state:
set_snowpark_session(get_snowflake_connection())

with tempfile.TemporaryDirectory() as temp_dir:
# Downloads the YAML to {temp_dir}/{file_name}.
st.session_state.session.file.get(
Expand Down

0 comments on commit c5ed4bf

Please sign in to comment.