Skip to content

Commit 50937a2

Browse files
committed
test fixes
1 parent d439a6a commit 50937a2

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/snowflake/snowpark/context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@
5353

5454
# The fully qualified name of the Anaconda shared repository (conda channel).
5555
_ANACONDA_SHARED_REPOSITORY = "snowflake.snowpark.anaconda_shared_repository"
56-
# In case of failures or the current default artifact repository is unset, we fallback to this
57-
# TODO: undo this when the system function NULL behavior starts working again
56+
# The fully qualified name of the PyPI shared repository (pypi channel).
57+
_PYPI_SHARED_REPOSITORY = "snowflake.snowpark.pypi_shared_repository"
58+
# In case of failures and for routing to the right session package store, we use this
5859
_DEFAULT_ARTIFACT_REPOSITORY = (
5960
_ANACONDA_SHARED_REPOSITORY
6061
if sys.version_info <= (3, 13)
61-
else "snowflake.snowpark.pypi_shared_repository"
62+
else _PYPI_SHARED_REPOSITORY
6263
)
6364

6465

tests/integ/test_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
_get_active_session,
4343
_get_active_sessions,
4444
)
45-
from snowflake.snowpark.context import _ANACONDA_SHARED_REPOSITORY
45+
from snowflake.snowpark.context import _DEFAULT_ARTIFACT_REPOSITORY
4646
from tests.utils import IS_IN_STORED_PROC, IS_IN_STORED_PROC_LOCALFS, TestFiles, Utils
4747

4848

@@ -1115,5 +1115,5 @@ def mock_session_parameters(param: str, quoted: bool = True):
11151115
mock_session_parameters,
11161116
), caplog.at_level(logging.WARNING):
11171117
result = session._get_default_artifact_repository()
1118-
assert result == _ANACONDA_SHARED_REPOSITORY
1118+
assert result == _DEFAULT_ARTIFACT_REPOSITORY
11191119
assert caplog.text.count("Error getting default artifact repository") == 0

tests/unit/test_session.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
SnowparkSessionException,
3030
)
3131
from snowflake.snowpark.session import _PYTHON_SNOWPARK_USE_SCOPED_TEMP_OBJECTS_STRING
32-
from snowflake.snowpark.context import _ANACONDA_SHARED_REPOSITORY
32+
from snowflake.snowpark.context import (
33+
_ANACONDA_SHARED_REPOSITORY,
34+
_DEFAULT_ARTIFACT_REPOSITORY,
35+
)
3336
from snowflake.snowpark.types import StructField, StructType
3437

3538

@@ -351,10 +354,10 @@ def assert_packages(packages):
351354
def test_resolve_packages_optional_artifact_repository(mock_server_connection):
352355
session = Session(mock_server_connection)
353356
session._get_default_artifact_repository = MagicMock(
354-
return_value="snowflake.snowpark.pypi_shared_repository"
357+
return_value="test_artifact_repo"
355358
)
356359
session._artifact_repository_packages = {
357-
"snowflake.snowpark.pypi_shared_repository": {
360+
"test_artifact_repo": {
358361
"numpy": "numpy==1.0.0",
359362
}
360363
}
@@ -762,6 +765,7 @@ def test_get_default_artifact_repository():
762765

763766
assert mocked_run_query.call_count == 1
764767

768+
# TODO: remove this test when the system function NULL behavior starts working again?
765769
with mock.patch.object(
766770
session, "_run_query", return_value=[[None]]
767771
) as mocked_run_query, mock.patch.object(
@@ -770,7 +774,7 @@ def test_get_default_artifact_repository():
770774
session, "get_current_schema", return_value="SCHEMA2"
771775
):
772776
result = session._get_default_artifact_repository()
773-
assert result == _ANACONDA_SHARED_REPOSITORY
777+
assert result == _DEFAULT_ARTIFACT_REPOSITORY
774778

775779
assert mocked_run_query.call_count == 1
776780

@@ -799,6 +803,6 @@ def test_infer_is_return_table_uses_internal_describe():
799803
session, "get_current_schema", return_value="SCHEMA1"
800804
):
801805
result = session._get_default_artifact_repository()
802-
assert result == _ANACONDA_SHARED_REPOSITORY
806+
assert result == _DEFAULT_ARTIFACT_REPOSITORY
803807

804808
assert mocked_run_query.call_count == 1

tests/unit/test_stored_procedure.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ def mock_callback(extension_function_properties):
149149
== f"{sys.version_info[0]}.{sys.version_info[1]}"
150150
)
151151
assert callableProperties.all_imports == ""
152+
# TODO: for python 3.14, it will use PyPI so we should also check for cloudpickle
152153
assert (
153-
callableProperties.all_packages
154-
== f"'snowflake-snowpark-python=={'.'.join(map(str, VERSION))}'"
154+
f"'snowflake-snowpark-python=={'.'.join(map(str, VERSION))}'"
155+
in callableProperties.all_packages
155156
)
156157
assert callableProperties.external_access_integrations is None
157158
assert callableProperties.secrets is None

tests/unit/test_udf_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_resolve_imports_and_packages_in_sandbox():
149149
assert handler is None
150150
assert inline_code is None
151151
assert all_imports == ""
152-
assert all_packages == ",".join([f"'{package}'" for package in packages])
152+
assert all(f"'{package}'" in all_packages for package in packages)
153153
assert upload_file_stage_location is None
154154
assert not custom_python_runtime_version_allowed
155155

@@ -208,7 +208,7 @@ def test_resolve_imports_and_packages_imports_as_str(tmp_path_factory):
208208
assert handler is None
209209
assert inline_code is None
210210
assert all_imports == ""
211-
assert all_packages == ",".join([f"'{package}'" for package in packages])
211+
assert all(f"'{package}'" in all_packages for package in packages)
212212
assert upload_file_stage_location is None
213213
assert not custom_python_runtime_version_allowed
214214

0 commit comments

Comments
 (0)