diff --git a/src/snowflake/cli/_plugins/streamlit/streamlit_entity_model.py b/src/snowflake/cli/_plugins/streamlit/streamlit_entity_model.py index 98fe54c69f..55068adb5a 100644 --- a/src/snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +++ b/src/snowflake/cli/_plugins/streamlit/streamlit_entity_model.py @@ -50,23 +50,14 @@ class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBase default=None, ) - @model_validator(mode="after") - def main_file_must_be_in_artifacts(self): - if not self.artifacts: - return self - - if Path(self.main_file) not in self.artifacts: - raise ValueError( - f"Specified main file {self.main_file} is not included in artifacts." - ) - return self - @model_validator(mode="after") def artifacts_must_exists(self): if not self.artifacts: return self for artifact in self.artifacts: + if "*" in artifact.name: + continue if not artifact.exists(): raise ValueError( f"Specified artifact {artifact} does not exist locally." diff --git a/tests/streamlit/__snapshots__/test_commands.ambr b/tests/streamlit/__snapshots__/test_commands.ambr index 2e525c5430..a849210505 100644 --- a/tests/streamlit/__snapshots__/test_commands.ambr +++ b/tests/streamlit/__snapshots__/test_commands.ambr @@ -14,21 +14,6 @@ ''' # --- -# name: test_main_file_must_be_in_artifacts - ''' - +- Error ----------------------------------------------------------------------+ - | During evaluation of DefinitionV20 in project definition following errors | - | were encountered: | - | For field entities.my_streamlit.streamlit you provided '{'artifacts': | - | ['streamlit_app.py', 'utils/utils.py', 'pages/', 'environment.yml'], | - | 'identifier': 'test_streamlit_deploy_snowcli', 'main_file': 'foo_bar.py', | - | 'query_warehouse': 'xsmall', 'stage': 'streamlit', 'title': 'My Fancy | - | Streamlit', 'type': 'streamlit'}'. This caused: Value error, Specified main | - | file foo_bar.py is not included in artifacts. | - +------------------------------------------------------------------------------+ - - ''' -# --- # name: test_multiple_streamlit_raise_error_if_multiple_entities ''' Usage: default streamlit deploy [OPTIONS] [ENTITY_ID] diff --git a/tests/streamlit/test_commands.py b/tests/streamlit/test_commands.py index 35d69f6310..9e22811744 100644 --- a/tests/streamlit/test_commands.py +++ b/tests/streamlit/test_commands.py @@ -266,23 +266,6 @@ def test_deploy_only_streamlit_file_replace( mock_typer.launch.assert_not_called() -def test_main_file_must_be_in_artifacts( - runner, mock_ctx, project_directory, alter_snowflake_yml, snapshot -): - with project_directory("example_streamlit_v2") as pdir: - alter_snowflake_yml( - pdir / "snowflake.yml", - parameter_path="entities.my_streamlit.main_file", - value="foo_bar.py", - ) - - result = runner.invoke( - ["streamlit", "deploy"], - ) - assert result.exit_code == 1 - assert result.output == snapshot - - def test_artifacts_must_exists( runner, mock_ctx, project_directory, alter_snowflake_yml, snapshot ): diff --git a/tests_integration/test_streamlit.py b/tests_integration/test_streamlit.py index 64943a3acf..0da14a626d 100644 --- a/tests_integration/test_streamlit.py +++ b/tests_integration/test_streamlit.py @@ -135,6 +135,27 @@ def test_streamlit_deploy_with_imports( assert result.json[0]["import_urls"] == '["@stage/foo.py","@stage/bar.py"]' +@pytest.mark.integration +@pytest.mark.parametrize("pattern", ["*.py", "*"]) +def test_streamlit_deploy_with_glob_patterns( + pattern, + runner, + snowflake_session, + test_database, + _new_streamlit_role, + project_directory, + alter_snowflake_yml, +): + with project_directory(f"streamlit_v2"): + alter_snowflake_yml( + "snowflake.yml", "entities.my_streamlit.artifacts", [pattern] + ) + result = runner.invoke_with_connection_json( + ["streamlit", "deploy", "--replace"] + ) + assert result.exit_code == 0 + + @pytest.mark.integration @pytest.mark.skip( reason="only works in accounts with experimental checkout behavior enabled"