Skip to content

Commit 026c024

Browse files
committed
cleanup
1 parent e2b71f0 commit 026c024

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### New Features
88

99
- Added support for the `DECFLOAT` data type that allows users to represent decimal numbers exactly with 38 digits of precision and a dynamic base-10 exponent.
10+
- Added support for the `DEFAULT_PYTHON_ARTIFACT_REPOSITORY` parameter that allows users to configure the default artifact repository at the account, database, and schema level.
1011

1112
#### Bug Fixes
1213

src/snowflake/snowpark/_internal/udf_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,13 +1227,16 @@ def resolve_imports_and_packages(
12271227
Optional[str],
12281228
bool,
12291229
]:
1230-
from snowflake.snowpark.session import ANACONDA_SHARED_REPOSITORY
1230+
from snowflake.snowpark.session import (
1231+
ANACONDA_SHARED_REPOSITORY,
1232+
DEFAULT_ARTIFACT_REPOSITORY,
1233+
)
12311234

12321235
if artifact_repository is None:
12331236
artifact_repository = (
12341237
session._get_default_artifact_repository()
12351238
if session
1236-
else ANACONDA_SHARED_REPOSITORY
1239+
else DEFAULT_ARTIFACT_REPOSITORY
12371240
)
12381241

12391242
existing_packages_dict = (

src/snowflake/snowpark/session.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@
323323

324324
# The fully qualified name of the Anaconda shared repository (conda channel).
325325
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
326328

327329

328330
def _get_active_session() -> "Session":
@@ -608,8 +610,8 @@ def __init__(
608610
] = defaultdict(dict)
609611
# Single-entry cache for the default artifact repository value.
610612
# Stores a tuple of ((database, schema), cached_value). Only one entry is
611-
# kept at a time – switching to a different database/schema evicts the old
612-
# value and triggers a fresh query on the next call.
613+
# kept at a time – switching to a different database/schema will evict the old
614+
# value and trigger a fresh query on the next call.
613615
self._default_artifact_repository_cache: Optional[
614616
Tuple[Tuple[Optional[str], Optional[str]], str]
615617
] = None
@@ -1641,7 +1643,8 @@ def add_packages(
16411643
for this argument. If a ``module`` object is provided, the package will be
16421644
installed with the version in the local environment.
16431645
artifact_repository: When set this parameter specifies the artifact repository that packages will be added from. Only functions
1644-
using that repository will use the packages. (Default None)
1646+
using that repository will use the packages. (Default None). Otherwise, uses the default artifact repository configured in the
1647+
current context.
16451648
16461649
Example::
16471650
@@ -1701,7 +1704,8 @@ def remove_package(
17011704
Args:
17021705
package: The package name.
17031706
artifact_repository: When set this parameter specifies that the package should be removed
1704-
from the default packages for a specific artifact repository.
1707+
from the default packages for a specific artifact repository. Otherwise, uses the default
1708+
artifact repository configured in the current context.
17051709
17061710
Examples::
17071711
@@ -1758,7 +1762,8 @@ def add_requirements(
17581762
Args:
17591763
file_path: The path of a local requirement file.
17601764
artifact_repository: When set this parameter specifies the artifact repository that packages will be added from. Only functions
1761-
using that repository will use the packages. (Default None)
1765+
using that repository will use the packages. (Default None). Otherwise, uses the default artifact repository configured in
1766+
the current context.
17621767
17631768
Example::
17641769
@@ -2402,7 +2407,7 @@ def _get_default_artifact_repository(self) -> str:
24022407
fallback needs to be updated here.
24032408
"""
24042409
if isinstance(self._conn, MockServerConnection):
2405-
return ANACONDA_SHARED_REPOSITORY
2410+
return DEFAULT_ARTIFACT_REPOSITORY
24062411

24072412
cache_key = (self.get_current_database(), self.get_current_schema())
24082413

@@ -2418,12 +2423,12 @@ def _get_default_artifact_repository(self) -> str:
24182423
f"SELECT SYSTEM$GET_DEFAULT_PYTHON_ARTIFACT_REPOSITORY('{python_version}')"
24192424
)
24202425
value = result[0][0] if result else None
2421-
resolved = value or ANACONDA_SHARED_REPOSITORY
2426+
resolved = value or DEFAULT_ARTIFACT_REPOSITORY
24222427
except Exception as e:
24232428
_logger.warning(
24242429
f"Error getting default artifact repository: {e}. Using fallback."
24252430
)
2426-
resolved = ANACONDA_SHARED_REPOSITORY
2431+
resolved = DEFAULT_ARTIFACT_REPOSITORY
24272432

24282433
with self._package_lock:
24292434
self._default_artifact_repository_cache = (cache_key, resolved)

src/snowflake/snowpark/stored_procedure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,12 +941,12 @@ def _do_register_sp(
941941

942942
effective_artifact_repository = artifact_repository
943943
if effective_artifact_repository is None:
944-
from snowflake.snowpark.session import ANACONDA_SHARED_REPOSITORY
944+
from snowflake.snowpark.session import DEFAULT_ARTIFACT_REPOSITORY
945945

946946
effective_artifact_repository = (
947947
self._session._get_default_artifact_repository()
948948
if self._session
949-
else ANACONDA_SHARED_REPOSITORY
949+
else DEFAULT_ARTIFACT_REPOSITORY
950950
)
951951

952952
# Add in snowflake-snowpark-python if it is not already in the package list.

0 commit comments

Comments
 (0)