Skip to content

Commit a04e507

Browse files
committed
move constants to context + temp schema in test
1 parent 4f3d174 commit a04e507

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

src/snowflake/snowpark/_internal/udf_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
)
6060
from snowflake.snowpark.types import DataType, StructField, StructType
6161
from snowflake.snowpark.version import VERSION
62+
from snowflake.snowpark.context import (
63+
_ANACONDA_SHARED_REPOSITORY,
64+
_DEFAULT_ARTIFACT_REPOSITORY,
65+
)
6266

6367
if installed_pandas:
6468
from snowflake.snowpark.types import (
@@ -1227,11 +1231,6 @@ def resolve_imports_and_packages(
12271231
Optional[str],
12281232
bool,
12291233
]:
1230-
from snowflake.snowpark.session import (
1231-
_ANACONDA_SHARED_REPOSITORY,
1232-
_DEFAULT_ARTIFACT_REPOSITORY,
1233-
)
1234-
12351234
if artifact_repository is None:
12361235
artifact_repository = (
12371236
session._get_default_artifact_repository()

src/snowflake/snowpark/context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
# example: _integral_type_default_precision = {IntegerType: 9}, IntegerType default _precision is 9 now
4949
_integral_type_default_precision = {}
5050

51+
# The fully qualified name of the Anaconda shared repository (conda channel).
52+
_ANACONDA_SHARED_REPOSITORY = "snowflake.snowpark.anaconda_shared_repository"
53+
# In case of failures or the current default artifact repository is unset, we fallback to this
54+
_DEFAULT_ARTIFACT_REPOSITORY = _ANACONDA_SHARED_REPOSITORY
55+
5156

5257
def configure_development_features(
5358
*,

src/snowflake/snowpark/session.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@
156156
from snowflake.snowpark.context import (
157157
_is_execution_environment_sandboxed_for_client,
158158
_use_scoped_temp_objects,
159+
_ANACONDA_SHARED_REPOSITORY,
160+
_DEFAULT_ARTIFACT_REPOSITORY,
159161
)
160162
from snowflake.snowpark.dataframe import DataFrame
161163
from snowflake.snowpark.dataframe_reader import DataFrameReader
@@ -321,11 +323,6 @@
321323
WRITE_PANDAS_CHUNK_SIZE: int = 100000 if is_in_stored_procedure() else None
322324
WRITE_ARROW_CHUNK_SIZE: int = 100000 if is_in_stored_procedure() else None
323325

324-
# The fully qualified name of the Anaconda shared repository (conda channel).
325-
_ANACONDA_SHARED_REPOSITORY = "snowflake.snowpark.anaconda_shared_repository"
326-
# In case of failures or the current default artifact repository is unset, we fallback to this
327-
_DEFAULT_ARTIFACT_REPOSITORY = _ANACONDA_SHARED_REPOSITORY
328-
329326

330327
def _get_active_session() -> "Session":
331328
with _session_management_lock:

tests/integ/test_packaging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
get_signature,
2121
)
2222
from snowflake.snowpark.functions import call_udf, col, count_distinct, sproc, udf
23-
from snowflake.snowpark.session import _ANACONDA_SHARED_REPOSITORY
23+
from snowflake.snowpark.context import _ANACONDA_SHARED_REPOSITORY
2424
from snowflake.snowpark.types import DateType, StringType
2525
from tests.utils import IS_IN_STORED_PROC, TempObjectType, TestFiles, Utils
2626

tests/integ/test_udf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,9 @@ def test_urllib() -> str:
30833083
)
30843084
def test_use_default_artifact_repository(db_parameters):
30853085
with Session.builder.configs(db_parameters).create() as session:
3086-
session.use_schema("public")
3086+
temp_stage = Utils.random_temp_schema()
3087+
session.sql(f"create schema {temp_stage}").collect()
3088+
session.sql(f"use schema {temp_stage}").collect()
30873089
session.sql(
30883090
"ALTER SESSION SET ENABLE_DEFAULT_PYTHON_ARTIFACT_REPOSITORY = true"
30893091
).collect()
@@ -3115,4 +3117,4 @@ def test_art() -> str:
31153117
finally:
31163118
session._run_query(f"drop function if exists {temp_func_name}(int)")
31173119

3118-
session.sql("ALTER schema unset DEFAULT_PYTHON_ARTIFACT_REPOSITORY").collect()
3120+
session.sql(f"drop schema {temp_stage}").collect()

tests/unit/test_session.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
SnowparkInvalidObjectNameException,
2929
SnowparkSessionException,
3030
)
31-
from snowflake.snowpark.session import (
32-
_PYTHON_SNOWPARK_USE_SCOPED_TEMP_OBJECTS_STRING,
33-
_ANACONDA_SHARED_REPOSITORY,
34-
)
31+
from snowflake.snowpark.session import _PYTHON_SNOWPARK_USE_SCOPED_TEMP_OBJECTS_STRING
32+
from snowflake.snowpark.context import _ANACONDA_SHARED_REPOSITORY
3533
from snowflake.snowpark.types import StructField, StructType
3634

3735

tests/unit/test_udf_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
resolve_packages_in_client_side_sandbox,
2727
)
2828
from snowflake.snowpark._internal.utils import TempObjectType
29-
from snowflake.snowpark.session import _ANACONDA_SHARED_REPOSITORY
29+
from snowflake.snowpark.context import _ANACONDA_SHARED_REPOSITORY
3030
from snowflake.snowpark.types import StringType
3131
from snowflake.snowpark.version import VERSION
3232

0 commit comments

Comments
 (0)