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.
definition_version: 1
snowpark:
project_name: "my_snowpark_project"
stage_name: "dev_deployment"
src: "app/"
functions:
- name: hello_function
handler: "functions.hello_function"
signature:
- name: "name"
type: "string"
returns: string
external_access_integration:
- my_external_access
secrets:
cred: my_cred_name
- name: test_function
handler: "functions.hello_function"
signature: ""
returns: string
procedures:
- name: hello_procedure
handler: "procedures.hello_procedure"
signature:
- name: "name"
type: "string"
returns: string
- name: test_procedure
handler: "procedures.test_procedure"
signature: ""
returns: string
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.
Project definition properties¶
The following table describes the project definition properties.
Property |
Definition |
---|---|
definition_version required, int |
Version of the project definition schema, which is currently 1. |
snowpark.project_name required, string |
Project identifier. |
snowpark.stage_name required, string |
Stage in which project’s artifacts will be stored. |
snowpark.src required, int |
The |
snowpark.functions optional, int |
List of functions defined in the project. See Function and procedure object properties for more details. |
snowpark.procedures optional, int |
List of procedures defined in the project. See Function and procedure object properties for more details. |
Function and procedure object properties¶
The following table describes the properties used by functions and procedures.
Property |
Definition |
---|---|
name required, string |
Object identifier. You can specify either the name or the fully-qualified name of the function or procedure. If you specify a fully-qualified name, such as functions:
# valid fully-qualified function name
# with no database or schema properties
- name: "mydb.schema1.my-function"
# valid function name with
# database and schema properties
- name: "my-function"
database: "mydb"
schema: "schema1"
# invalid fully-qualified function name
# with database and schema properties
- name: "mydb.schema1.my-function"
database: "mydb"
schema: "schema1"
|
handler required, string |
Function’s or procedure’s implementation of the object inside module defined in |
returns required, string |
Type of the result. Check the list of available types. |
signature required, sequence |
The signature:
- name: "first_argument"
type: int
- name: "second_argument"
default: "default value"
type: string
If a function or procedure takes no arguments, set this value to an empty string ( Check the list 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.8”. |
external_access_integration optional, string sequence |
Names of external access integrations needed for this procedure’s handler code to access external networks. See CREATE PROCEDURE for more details. |
database optional, string |
Name of the database for the function or procedure. Default: None. An error occurs if you specify this property and use a fully-qualified name in the |
schema optional, string |
Name of the schema for the function or procedure. Default: None. An error occurs if you specify this property and use a fully-qualified name in the |
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 CREATE PROCEDURE for more details. |
imports optional, string sequence |
Stage and path to previously uploaded files you want to import. See 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). |