From bdf0707fe37911a44344b1f1057dc8df617425ea Mon Sep 17 00:00:00 2001 From: Afroz Alam Date: Wed, 20 Sep 2023 17:46:53 -0700 Subject: [PATCH 1/2] SNOW-903907: Fix custom package uplaod bug --- src/snowflake/snowpark/session.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/snowflake/snowpark/session.py b/src/snowflake/snowpark/session.py index 57ab2cdadcf..59b30803301 100644 --- a/src/snowflake/snowpark/session.py +++ b/src/snowflake/snowpark/session.py @@ -1169,11 +1169,15 @@ def get_req_identifiers_list( # 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." + ) + else: + result_dict[name] = str(package) else: result_dict[name] = str(package) @@ -1707,7 +1711,6 @@ def connection(self) -> "SnowflakeConnection": and Snowflake server.""" return self._conn._conn - def _run_query( self, query: str, From 8ce10875d627eb15a8c67edfde9d7742e0cd1495 Mon Sep 17 00:00:00 2001 From: Afroz Alam Date: Fri, 22 Sep 2023 10:57:48 -0700 Subject: [PATCH 2/2] SNOW-903907: add comment about result dict structure --- src/snowflake/snowpark/session.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/snowflake/snowpark/session.py b/src/snowflake/snowpark/session.py index 59b30803301..6313fd6d195 100644 --- a/src/snowflake/snowpark/session.py +++ b/src/snowflake/snowpark/session.py @@ -1167,6 +1167,12 @@ 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: @@ -1176,8 +1182,7 @@ def get_req_identifiers_list( f"Cannot add dependency package '{name}=={version}' " f"because {result_dict[name]} is already added." ) - else: - result_dict[name] = str(package) + result_dict[name] = str(package) else: result_dict[name] = str(package)