Skip to content

Instantly share code, notes, and snippets.

@ben-nour
Last active August 13, 2026 01:07
Show Gist options
  • Select an option

  • Save ben-nour/d20d21657d185df3d34f717faeef65c0 to your computer and use it in GitHub Desktop.

Select an option

Save ben-nour/d20d21657d185df3d34f717faeef65c0 to your computer and use it in GitHub Desktop.
Automating Workspace noteboook execution via Snowflake Tasks

🤖 Automating Workspace noteboook execution via Snowflake Tasks

Written: 12 August 2026

From September 2026 Legacy notebook creation will be disabled and new Snowflake notebooks will need to be created via Workspaces.

Scheduling workspace notebook execution via Snowflake Task is slightly more complicated than with Legacy notebooks and this guide runs you through the steps for creating and debugging tasks that execute workspace notebooks.

Prerequisites

To automate the execution of a workspace notebook you’ll need both the CREATE NOTEBOOK PROJECT and CREATE TASK privileges granted on your role.

Step 1 - Creating a notebook project

A workspace is a private, file-based environment which each Snowflake user has access to.

Any files you create in Snowsight (SQL scripts, notebooks, etc) are part of your workspace.

A Notebook Project Object (NPO) links a workspace to a database and schema and is needed as Snowflake Tasks don’t execute notebooks directly (like they did with Legacy notebooks) but instead execute NPOs.

-- To see all the files in your Workspace:
LIST 'snow://workspace/USER$.PUBLIC.DEFAULT$/versions/head' ;

When NPO is created, all files from the workspace are copied into the project in the specified database and schema (including the Snowflake notebooks we want to automate).

⚠️

If you make a change to a file in your Workspace your NPO will need to be recreated to reflect this change.

-- Creating the notebook project:
CREATE OR REPLACE NOTEBOOK PROJECT YOUR_DATABASE.YOUR_SCHEMA.ben_test_project
FROM 'snow://workspace/USER$.PUBLIC.DEFAULT$/versions/head/'
;

-- Verify the notebook project exists:
SHOW notebook projects ;

Step 2 - creating a Snowflake task

Now that you’ve created a NPO you can create a Snowflake Task that executes the project.

Importantly you’ll want to specify the notebook file you want executed via the MAIN_FILE parameter:

CREATE OR REPLACE TASK YOUR_DATABASE.YOUR_SCHEMA.BEN_NOTEBOOK_EXECUTION
	WAREHOUSE=YOUR_WAREHOUSE
	schedule='USING CRON 30 10 * * * Australia/Sydney'
	AS
	  	EXECUTE NOTEBOOK PROJECT YOUR_DATABASE.YOUR_SCHEMA.ben_test_project
	    MAIN_FILE = 'ben_notebook.ipynb'
	    COMPUTE_POOL = 'SYSTEM_COMPUTE_POOL_CPU'
	    QUERY_WAREHOUSE = 'YOUR_WAREHOUSE'
	    RUNTIME = 'v2.3-CPU-PY3.12'
	    -- Optional, depending on what your notebook does:
	    --EXTERNAL_ACCESS_INTEGRATIONS = SLACK_WEBOOK_INTEGRATION
;

If your notebook uses an integration you’ll need to specify this too, via the EXTERNAL_ACCESS_INTEGRATIONS parameter.

For a full list of parameters see the official documentation.

Debugging 🔍

Checking run history

If a task fails to run you can see more detail about what caused the failure by using Snowsight to view the task results.

Navigate to Catalog - Your Database - Your Schema - Notebook Projects - Your Notebook Project and click the Results hyperlink.

There’s also an error message field which tells you information about the nature of the error.

Debugging checklist ✅

Usually the run history will tell you why the task failed but if not verify the following isn’t causing an issue:

  • Have you specified the external access integration (EAI) needed in the Snowflake Task definition?
    • Does your EAI use a secret that your role does not have access to?
  • Is your Notebook Project updated with the latest changes to files in your workspace? E.g. if you fixed a typo in your notebook have you recreated the Notebook Project so the task is accessing the corrected version of the notebook?
  • Have you fully qualified all object references in your notebook (e.g. YOUR_DATABASE.YOUR_SCHEMA.YOUR_TABLE and/or specified session variables (USE SCHEMA YOUR_SCHEMA;)?

Official documentation 📄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment