Setting up an IDE for using Snowpark Checkpoints

The Snowflake Extension for Visual Studio Code offers support for the Snowpark Checkpoints library to enhance the experience of using the framework. It gives you fine-grained control over the collect and validate statements inserted into your code, as well as reviews the status of the behavioral-equivalence assertions of your converted code.

Enabling Snowpark Checkpoints

To enable Snowpark Checkpoints, go to Snowflake’s extension settings and check Snowpark Checkpoints: Enabled.

Enabled checkpoints

View

Setting the Snowpark Checkpoints property to Enabled, as explained previously, will open a new tab in the extension called SNOWPARK CHECKPOINTS. It displays all checkpoints in the workspace and enables multiple actions to be performed, such as enabling/disabling all or individually, clearing all from files, and by double-clicking each checkpoint, navigates to the file and line of code where it is defined.

Toggle all checkpoints

Located at the top right corner of the Snowpark Checkpoints tab, this option toggles the enabled property in all checkpoints.

Toggle checkpoints

Enabled checkpoints:

Toggle checkpoints

Disabling a checkpoint leads to it being skipped at runtime.

Disable checkpoints

Cleaning up all checkpoints

Located at the top right corner of the Snowpark Checkpoints tab. This removes checkpoints from all Python files, including Jupyter notebooks, in your workspace, but it does not delete them from the contract and panel. That means they can be restored using the command Snowflake: Restore All Checkpoints.

Remove checkpoints

Inserting checkpoints in a file

Right-clicking inside a file will display a context menu containing the Snowpark Checkpoints option, which allows adding Collection and Validation checkpoints.

Snowpark checkpoints option in context menu:

Add checkpoints

Collector/Validator added:

Collector and validator checkpoints

Running a single checkpoint

A single checkpoint can be run by clicking the code lens option shown above each checkpoint. Running it will bring up an output console showing the progress and once it finishes will pull up the results view. Even if the checkpoint is disabled in the contract file, it will be enabled just for its execution.

Running a single checkpoint

If an entry point is not declared in the contract file the error message: Entry point not found for the checkpoint. will be displayed.

Entry point not found

Running all enabled Snowpark Checkpoints in a file

In the top right corner of each file, the Run all checkpoints from the current file button will be present.

Running all checkpoints

Clicking on it will bring up an output channel displaying the progress of the execution.

Checkpoints progress

Timeline view

Displays a timeline of the checkpoints execution results.

Timeline view

Commands

The following commands are available for Snowpark Checkpoints. To use them enter Snowflake: [command name] into the command palette.

Snowpark Checkpoints commands

Command

Description

Snowflake: Toggle Checkpoints

Toggles the enabled property of all checkpoints.

Snowflake: Snowpark Checkpoints Project Initialization

Triggers project initialization, creating a contract file if it doesn’t exist. In case it exists, a pop-up displays, asking if you want to load the checkpoint into the contract file.

Snowflake: Clear All Checkpoints

Deletes all checkpoints from all files in the workspace.

Snowflake: Restore All Checkpoints

Restore checkpoints previously deleted from files that are still present in the contract file.

Snowflake: Add Validation/Collection Checkpoint

Adds a validator or collector with its mandatory parameters at the cursor position.

Snowflake: Focus on Snowpark Checkpoints View

Shifts focus to the panel SNOWPARK CHECKPOINTS.

Snowflake: Open Checkpoints Timeline

Displays a timeline of Checkpoints executions.

Snowflake: Run all Checkpoints from the current file

Runs all enabled checkpoints in the current file.

Snowflake: Run all Checkpoints in the workspace

Runs all enabled checkpoints from the workspace.

Snowflake: Show All Snowpark Checkpoints Result

Displays a tab with all checkpoints results.

Warnings

  • Duplicate: In a collection project, if two checkpoints are assigned with the same name, a warning : “Another checkpoint with an identical name has been detected and will be overwritten.” Validation projects can have multiple checkpoints sharing the same name, no warning will be shown.

  • Wrong type: Adding a checkpoint with a different type than the project type will underline it with the following error message: “Please make sure you are using the correct Snowpark-Checkpoints statement. This particular checkpoint statement is different from the others used in this project, statements that don’t match the project type will be ignored when executed.”

  • Invalid checkpoint name: There are invalid ways to add a checkpoint name parameter. If this happens, a warning message will be displayed: “Invalid checkpoint name. Checkpoint names must start with a letter and can only contain letters, numbers, hyphens, and underscores”.