diff --git a/src/snowflake/cli/_plugins/snowpark/commands.py b/src/snowflake/cli/_plugins/snowpark/commands.py index fb0c64cc14..009bd7b0d4 100644 --- a/src/snowflake/cli/_plugins/snowpark/commands.py +++ b/src/snowflake/cli/_plugins/snowpark/commands.py @@ -440,11 +440,14 @@ def build( requirements=download_result.anaconda_packages, ) - cli_console.step(f"Creating {project_paths.dependencies.name}") - zip_dir( - source=temp_deps_dir.path, - dest_zip=project_paths.dependencies, - ) + if any(temp_deps_dir.path.iterdir()): + cli_console.step(f"Creating {project_paths.dependencies.name}") + zip_dir( + source=temp_deps_dir.path, + dest_zip=project_paths.dependencies, + ) + else: + cli_console.step(f"No external dependencies.") artifacts = set() for entity in get_snowpark_entities(pd).values(): diff --git a/tests_integration/test_snowpark.py b/tests_integration/test_snowpark.py index ff75a43db6..fa1ad17e10 100644 --- a/tests_integration/test_snowpark.py +++ b/tests_integration/test_snowpark.py @@ -348,7 +348,9 @@ def test_snowpark_with_separately_created_package( with project_directory("snowpark_with_import") as p_dir: - _test_steps.snowpark_build_should_zip_files(additional_files=[Path("app.zip")]) + _test_steps.snowpark_build_should_zip_files( + additional_files=[Path("app.zip")], no_dependencies=True + ) _test_steps.snowpark_deploy_should_finish_successfully_and_return( [ @@ -464,7 +466,9 @@ def test_snowpark_default_arguments( ): database = test_database.upper() with project_directory("snowpark_with_default_values") as tmp_dir: - _test_steps.snowpark_build_should_zip_files(additional_files=[Path("app.zip")]) + _test_steps.snowpark_build_should_zip_files( + additional_files=[Path("app.zip")], no_dependencies=True + ) _test_steps.snowpark_deploy_should_finish_successfully_and_return( [ @@ -730,7 +734,7 @@ def test_build_skip_version_check( ) assert result.exit_code == 0, result.output assert "Build done." in result.output - assert "Creating dependencies.zip" in result.output + assert "Creating dependencies.zip" not in result.output assert "Creating: app.zip" in result.output diff --git a/tests_integration/testing_utils/snowpark_utils.py b/tests_integration/testing_utils/snowpark_utils.py index 887383d282..0844900ce5 100644 --- a/tests_integration/testing_utils/snowpark_utils.py +++ b/tests_integration/testing_utils/snowpark_utils.py @@ -163,10 +163,15 @@ def object_describe_should_return_entity_description( ) assert result.json is not None - def snowpark_build_should_zip_files(self, *args, additional_files=None) -> None: + def snowpark_build_should_zip_files( + self, *args, additional_files=None, no_dependencies=False + ) -> None: if not additional_files: additional_files = [] + if not no_dependencies: + additional_files.append(Path("dependencies.zip")) + current_files = set(Path(".").glob("**/*")) result = self._setup.runner.invoke_json( ["snowpark", "build", "--format", "JSON", *args] @@ -179,7 +184,6 @@ def snowpark_build_should_zip_files(self, *args, additional_files=None) -> None: assert_that_current_working_directory_contains_only_following_files( *current_files, - Path("dependencies.zip"), *additional_files, Path("requirements.snowflake.txt"), excluded_paths=[".packages"],