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_pathwhere unsupported pure Python packages will be persisted. To use a specific version of pip, you can set the environment variable- PIP_PATHto point to your pip executable. To use custom Python packages which are not purely Python, specify the- force_pushconfiguration 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_pathbut 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() - Note - These configurations allow custom package addition via - Session.add_requirements()and- Session.add_packages().
- These configurations also allow custom package addition for all UDFs or stored procedures created later in the current session. If you only want to add custom packages for a specific UDF, you can use - packagesargument in- functions.udf()or- session.udf.register().