Create a Snowpark project definition¶
The snowflake.yml file contains the functions and procedures declarations for a Snowpark project.
Note
Currently, the Snowpark project definition file must be named snowflake.yml.
The following snippet shows a sample Snowpark project definition file: with two functions and two procedures. The hello_function function uses external capabilities of Snowpark.
Caution
Files inside a project directory are processed by Snowflake CLI and could be uploaded to Snowflake when executing other snow snowpark commands. You should use caution when putting any sensitive information inside files in a project directory.
Note
Specifying Python dependencies in definition_version: 2
Python dependencies are declared in two places, depending on where the package comes from:
- Anaconda-channel packages (such as
snowflake-snowpark-python,pandas, ornumpy) must be listed in arequirements.txtfile in the project root. This file is automatically picked up bysnow snowpark deploy. - PyPI packages can go in that same
requirements.txtfile (Snowflake CLI packages them into a zip) or under the entitypackages:field, which requires theartifact_repository:field to also be set (typically tosnowflake.snowpark.pypi_shared_repository). Specifyingpackages:withoutartifact_repository:returns the error: “You specified packages / artifact_repository_packages without setting artifact_repository.”
The packages: field is new in definition_version: 2 and is only for artifact-repository packages. v1 projects declare dependencies in requirements.txt only. If you are migrating an existing v1 project, see snow helpers v1-to-v2.
Function and procedure object properties¶
The following table describes the properties used by functions and procedures.
Function and procedure object properties
| Property | Definition |
|---|---|
identifier optional, string | Optional Snowflake identifier for the entity. The value can have the following forms:
Both unquoted and quoted identifiers are supported. To use quoted identifiers, include the surrounding quotes in the YAML value (e.g.
Note An error occurs if you specify a |
type optional, string | Must be one of: function or procedure. |
artifact_repository optional, string | Name of the artifact repository. Snowflake has a default artifact repository called The
For packages that depend on specific architectures, you can define them in the For more information, see Packages built only for x86. |
artifact_repository_packages optional, string | Note This property has been deprecated in favor of the |
packages optional, string sequence | List of PyPI packages to install from the artifact repository specified in You can also list PyPI packages in a project-root For Anaconda-channel packages (such as For example: |
artifacts required, string sequence | List of file source and destination pairs to add to the deploy root. You can use the following artifact properties:
Destination paths that reference directories must end with a Note Using glob patterns in Snowpark You can also pass in a string for each item instead of a If You can also pass in a string for each item instead of a |
handler required, string | Function’s or procedure’s implementation of the object inside module defined in snowpark.src. For example functions.hello_function refers to function hello_function from file <src>/functions.py. |
returns required, string | SQL type of the result. Check the list of available types. |
signature required, sequence | The If a function or procedure takes no arguments, set this value to an empty string ( Check the SQL Type column of available types. To learn more about the syntax of named and optional arguments, see Calling a UDF that has optional arguments. |
runtime optional, string | Python version to use when executing the procedure or function. Default: “3.12”. |
external_access_integrations optional, string sequence | Names of external access integrations needed for this procedure’s handler code to access external networks. See the EXTERNAL_ACCESS_INTEGRATIONS parameter in CREATE PROCEDURE for more details. |
secrets optional, dictionary | Assigns the names of secrets to variables so that you can use the variables to reference the secrets when retrieving information from secrets in handler code. See the SECRETS parameter in CREATE PROCEDURE for more details. |
imports optional, string sequence | Stage and path to previously uploaded files you want to import. See the IMPORT parameter in CREATE PROCEDURE for more details. |
execute_as_caller optional, bool | Available only for procedures. Determine whether the procedure is executed with the privileges of the owner (you) or with the privileges of the caller. Default: False (owner’s privileges). |