Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-903907: Fix custom package uplaod bug #1054

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,22 @@ def get_req_identifiers_list(
name = package.name
version = package.specs[0][1] if package.specs else None

# result_dict is a mapping of package name -> package_spec, example
# {'pyyaml': 'pyyaml==6.0',
# 'networkx': 'networkx==3.1',
# 'numpy': 'numpy',
# 'scikit-learn': 'scikit-learn==1.2.2',
# 'python-dateutil': 'python-dateutil==2.8.2'}
# Add to packages dictionary
if name in result_dict:
if version is not None and result_dict[name] != str(package):
raise ValueError(
f"Cannot add dependency package '{name}=={version}' "
f"because {result_dict[name]} is already added."
)
if version is not None:
added_package_has_version = "==" in result_dict[name]
if added_package_has_version and result_dict[name] != str(package):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment about what an entry of result_dict looks like and what package looks like? It's not obvious to me why result_dict[name] != str(package) is correct 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment to explain how things look

raise ValueError(
f"Cannot add dependency package '{name}=={version}' "
f"because {result_dict[name]} is already added."
)
result_dict[name] = str(package)
else:
result_dict[name] = str(package)

Expand Down Expand Up @@ -1707,7 +1716,6 @@ def connection(self) -> "SnowflakeConnection":
and Snowflake server."""
return self._conn._conn


def _run_query(
self,
query: str,
Expand Down
Loading