Skip to content

Commit

Permalink
SNOW-903907: Fix custom package uplaod bug (#1054)
Browse files Browse the repository at this point in the history
* SNOW-903907: Fix custom package uplaod bug

* SNOW-903907: add comment about result dict structure
  • Loading branch information
sfc-gh-aalam authored Sep 22, 2023
1 parent 100071a commit f88ff12
Showing 1 changed file with 14 additions and 6 deletions.
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):
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

0 comments on commit f88ff12

Please sign in to comment.