Skip to content

Commit

Permalink
[SNOW-1331499] Fixed ZIP packaging of snowpark project dependencies c…
Browse files Browse the repository at this point in the history
…ontaining implicit namespace packages (#1160)
  • Loading branch information
sfc-gh-pjob authored Jun 10, 2024
1 parent 4879554 commit 54a0e09
Show file tree
Hide file tree
Showing 3 changed files with 12 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 @@ -11,6 +11,7 @@
* `snow notebook create` proving an option to create a Snowflake Notebook from a file on stage.

## Fixes and improvements
* Fixed ZIP packaging of Snowpark project dependencies containing implicit namespace packages like `snowflake`.


# v2.4.0
Expand Down
9 changes: 6 additions & 3 deletions src/snowflake/cli/plugins/snowpark/zipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@

IGNORED_FILES = [
"**/.DS_Store",
"**/.git",
"**/.git/*",
"**/.gitignore",
"**/.env",
"**/.env/*",
"**/.venv",
"**/.venv/*",
"**/__pycache__",
"**/*.zip",
"**/*.pyc",
"**/env",
"**/env/*",
"**/ENV",
"**/ENV/*",
"**/venv",
"**/venv/*",
"**/requirements.txt",
"**/requirements.snowflake.txt",
Expand Down Expand Up @@ -52,9 +58,6 @@ def zip_dir(


def _to_be_zipped(file: Path) -> bool:
if file.is_dir():
return False

for pattern in IGNORED_FILES:
# This has to be a string because of fnmatch
file_as_str = str(file)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_zipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_zip_current_dir(temp_dir):
]
directories = [
Path(".git"),
Path("snowcli/.git"),
Path("bin"),
Path("snowcli"),
Path("snowcli/snowcli.dist-info"),
Expand All @@ -48,9 +49,13 @@ def test_zip_current_dir(temp_dir):
assert set(zip_file.namelist()) == {
"app.py",
"additional_module.py",
"bin/",
"bin/py.test",
"snowcli/",
"snowcli/snowcli.py",
"snowcli/snowcli.dist-info/",
"snowcli/snowcli.dist-info/METADATA.py",
"utils/",
"utils/utils.py",
}

Expand Down

0 comments on commit 54a0e09

Please sign in to comment.