Skip to content

Commit

Permalink
Merge branch 'main' into SNOW-1843926-spcs-event-table-snow-cli-integ…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
sfc-gh-ashen authored Dec 16, 2024
2 parents 7a30e43 + dae4e10 commit 59ed8b6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
## Backward incompatibility

## Deprecations
* Added deprecation message for default Streamlit warehouse

## New additions
* Add Release Directives support by introducing the following commands:
Expand Down
9 changes: 8 additions & 1 deletion src/snowflake/cli/_plugins/streamlit/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ def _create_streamlit(
query.append(f"MAIN_FILE = '{streamlit.main_file}'")
if streamlit.imports:
query.append(streamlit.get_imports_sql())
if streamlit.query_warehouse:

if not streamlit.query_warehouse:
cli_console.warning(
"[Deprecation] In next major version we will remove default query_warehouse='streamlit'."
)
query.append(f"QUERY_WAREHOUSE = 'streamlit'")
else:
query.append(f"QUERY_WAREHOUSE = {streamlit.query_warehouse}")

if streamlit.title:
query.append(f"TITLE = '{streamlit.title}'")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Streamlit(UpdatableModel, ObjectIdentifierModel(object_name="Streamlit")):
title="Stage in which the app’s artifacts will be stored", default="streamlit"
)
query_warehouse: str = Field(
title="Snowflake warehouse to host the app", default="streamlit"
title="Snowflake warehouse to host the app", default=None
)
main_file: Optional[Path] = Field(
title="Entrypoint file of the Streamlit app", default="streamlit_app.py"
Expand Down
1 change: 0 additions & 1 deletion tests/api/utils/test_definition_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def test_resolve_variables_in_project_cross_project_dependencies():
"streamlit": {
"name": "my_app",
"main_file": "streamlit_app.py",
"query_warehouse": "streamlit",
"stage": "streamlit",
},
"env": ProjectEnvironment(
Expand Down
38 changes: 38 additions & 0 deletions tests/streamlit/test_streamlit_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,44 @@ def test_deploy_streamlit_with_comment(
)


@mock.patch("snowflake.cli._plugins.streamlit.manager.StageManager")
@mock.patch("snowflake.cli._plugins.streamlit.manager.StreamlitManager.get_url")
@mock.patch("snowflake.cli._plugins.streamlit.manager.StreamlitManager.execute_query")
@mock_streamlit_exists
def test_deploy_streamlit_with_default_warehouse(
mock_execute_query, _, mock_stage_manager, temp_dir
):
mock_stage_manager().get_standard_stage_prefix.return_value = "stage_root"

main_file = Path(temp_dir) / "main.py"
main_file.touch()

st = StreamlitEntityModel(
type="streamlit",
identifier="my_streamlit_app",
title="MyStreamlit",
main_file=str(main_file),
artifacts=[main_file],
comment="This is a test comment",
)

StreamlitManager(MagicMock(database="DB", schema="SH")).deploy(
streamlit=st, replace=False
)

mock_execute_query.assert_called_once_with(
dedent(
f"""\
CREATE STREAMLIT IDENTIFIER('DB.SH.my_streamlit_app')
ROOT_LOCATION = 'stage_root'
MAIN_FILE = '{main_file}'
QUERY_WAREHOUSE = 'streamlit'
TITLE = 'MyStreamlit'
COMMENT = 'This is a test comment'"""
)
)


@mock.patch("snowflake.cli._plugins.streamlit.manager.StreamlitManager.execute_query")
@mock_streamlit_exists
def test_execute_streamlit(mock_execute_query):
Expand Down

0 comments on commit 59ed8b6

Please sign in to comment.