323323
324324# The fully qualified name of the Anaconda shared repository (conda channel).
325325ANACONDA_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
328330def _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 )
0 commit comments