This topic walks you through developing, deploying, and scheduling Python scripts in Snowflake on Warehouse or Compute Pools.
You can write and test your code locally using your favorite IDE or with Cortex Code, then deploy it as a Notebook
Project Object — a schema-levelobject that runs your script non-interactively on a warehouse or compute pool. Once deployed, you
can run your project on demand or schedule it with a task.
Run the demo script locally to verify your environment:
python src/main.py
Run the test suite:
python -m pytest
You can extend the sample scripts to read or write data specific to your team or use case.
Iterate locally until your script is ready, then configure and deploy it to Snowflake.
You can run the deploy commands in a CI/CD pipeline to automatically deploy your project when
you merge changes. The following example shows a GitHub Actions workflow that deploys on push to
the main branch:
If your script depends on User Defined Functions and you want to manage their lifecycle through
the project, create them during the script’s run with session.udf.register or the
@udf decorator. See src/udf_example.py in the sample project for an example.
Before you deploy, configure runtime and dependency settings in the snow_app.yml file
at the root of your project. This file sets default values so you don’t have to specify them every
time you run the project.
An example of the snow_app.yml file is shown below:
# This configuration will run the project files on Python 3.12 on the active warehouse# when the EXECUTE NOTEBOOK PROJECT command or `snow notebook project execute` command is used.runtime:version:python_3.12dependencies:requirements.txt
# This configuration will run the project files on the SYSTEM_COMPUTE_POOL_CPU compute pool# and use my_warehouse for any queries from the script when the EXECUTE NOTEBOOK PROJECT command# or `snow notebook project execute` command is used.runtime:version:"V2.3-CPU-PY3.12"compute_pool:SYSTEM_COMPUTE_POOL_CPUquery_warehouse:"my_warehouse"
A reference to the requirements.txt file that lists the Python dependencies for the project.
Dependencies are installed from the built-in snowflake.snowpark.pypi_shared_repository PyPI
repository.
dependencies:"requirements.txt"
If you split production and development dependencies, specify your production dependencies:
The artifact repository to use for the project. If not specified, the project uses the built-in snowflake.snowpark.pypi_shared_repository PyPI repository.
Usage: snow notebook project create [OPTIONS] [NAME]
Creates a notebook project in Snowflake.
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────╮
│ name [NAME] Name of the Snowpark project. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --source TEXT Source location of the notebook project. Supports stage path (starting │
│ with '@') or workspace path (starting with 'snow://workspace/'). │
│ --comment TEXT Comment for the notebook project. │
│ --overwrite Overwrite the notebook project if it already exists. │
│ --skip-if-exists Skip the creation of the notebook project if it already exists. │
│ --help -h Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Usage: snow notebook project execute [OPTIONS] [NAME] ARGUMENTS
Executes a notebook project in Snowflake.
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ name [NAME] Name of the notebook project. │
│ arguments TEXT Arguments to pass to the notebook project. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --main-file TEXT Main file of the notebook project. │
│ --compute-pool TEXT Compute pool to run the notebook project on. │
│ --query-warehouse TEXT Query warehouse to run the notebook project on. │
│ --runtime TEXT Runtime to run the notebook project on. │
│ --requirements-file TEXT Requirements file to use for the notebook project. │
│ --external-access-integrations TEXT External access integrations to use for the notebook project. │
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Usage: snow notebook project drop [OPTIONS] [NAME]
Drops a notebook project in Snowflake.
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ name [NAME] Name of the notebook project. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Usage: snow notebook project list [OPTIONS]
Lists notebook projects in Snowflake.
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯