You are viewing documentation about an older version (1.16.0). View latest version

snowflake.snowpark.Session.custom_package_usage_config¶

property Session.custom_package_usage_config: Dict[source]¶

Get or set configuration parameters related to usage of custom Python packages in Snowflake.

If enabled, pure Python packages that are not available in Snowflake will be installed locally via pip and made available as an import (see add_import() for more information on imports). You can speed up this process by mentioning a remote stage path as cache_path where unsupported pure Python packages will be persisted. To use a specific version of pip, you can set the environment variable PIP_PATH to point to your pip executable. To use custom Python packages which are not purely Python, specify the force_push configuration parameter (note that using non-pure Python packages is not recommended!).

This feature is experimental, please do not use it in production!

Configurations:
  • enabled (bool): Turn on usage of custom pure Python packages.

  • force_push (bool): Use Python packages regardless of whether the packages are pure Python or not.

  • cache_path (str): Cache custom Python packages on a stage directory. This parameter greatly reduces latency of custom package import.

  • force_cache (bool): Use this parameter if you specified a cache_path but wish to create a fresh cache of your environment.

Parameters:

config (dict) – Dictionary containing configuration parameters mentioned above (defaults to empty dictionary).

Example:

>>> from snowflake.snowpark.functions import udf
>>> session.custom_package_usage_config = {"enabled": True, "cache_path": "@my_permanent_stage/folder"} 
>>> session.add_packages("package_unavailable_in_snowflake") 
>>> @udf
... def use_my_custom_package() -> str:
...     import package_unavailable_in_snowflake
...     return "works"
>>> session.clear_packages()
>>> session.clear_imports()
Copy

Note