设置适用于使用 Snowpark Checkpoints 的 IDE¶
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 and also reviews the status of the behavioral-equivalence assertions of your converted code.
Enable Snowpark Checkpoints¶
- To enable Snowpark Checkpoints, in the Snowflake extension settings, select Snowpark Checkpoints: Enabled: 
 
视图¶
Setting the Snowpark Checkpoints property to Enabled opens a new tab in the extension called SNOWPARK CHECKPOINTS that displays all checkpoints in the workspace and enables multiple actions to be performed, such as enabling/disabling all or individual checkpoints or clearing all checkpoints from files. Double-clicking each checkpoint navigates to the file and line of code where it is defined.
切换所有检查点¶
- To enable or disable all checkpoints, select this control in the upper-right corner of the Snowpark Checkpoints tab: 
 
已启用的检查点:
 
Disabled checkpoints are skipped at runtime:
 
Remove all checkpoints¶
- To remove checkpoints from all Python files, including Jupyter notebooks, in your workspace, select this control in the upper-right corner of the Snowpark Checkpoints tab: 
 
The control does not remove the checkpoints from the contract and panel. They can be restored by using the command Snowflake: Restore All Checkpoints.
Insert a checkpoint in a file¶
- To insert a checkpoint in a file, right-click inside a file, and on the Snowpark Checkpoints menu, select Add Collection Checkpoint or Add Validation Checkpoint. 
Snowpark Checkpoints menu and options:
 
已添加收集器/验证器:
 
Run a single checkpoint¶
- To run a single checkpoint, select the code lens option displayed above the checkpoint: 
 
Running the checkpoint will open an output console that displays the progress and then the results view. Even if the checkpoint is disabled in the contract file, it will be enabled for its execution.
If an entry point is not declared in the contract file, the following error message is displayed: Entry point not found for the checkpoint.
 
Run all enabled Snowpark Checkpoints in a file¶
- To run all the enabled Checkpoints in a file, in the upper-right corner of the file, select Run all checkpoints from the current file: 
 
An output channel displays the progress:
 
时间轴视图¶
显示检查点执行结果的时间轴。
 
命令¶
The following commands are available for Snowpark Checkpoints. To use them, enter Snowflake: [command name]  into the command palette.
| 命令 | 描述 | 
|---|---|
| Snowflake:切换检查点 | 切换所有检查点的已启用属性。 | 
| Snowflake:Snowpark Checkpoints 项目初始化 | Triggers project initialization, creating a contract file if it doesn't exist. If the file exists, a display asks whether you want to load the checkpoint into the contract file. | 
| Snowflake:清除所有检查点 | 从工作区中的所有文件中删除所有检查点。 | 
| Snowflake:恢复所有检查点 | 恢复之前从已存在的合同文件中删除的检查点。 | 
| Snowflake:添加验证/收集检查点 | 在光标位置添加带有其强制参数的验证器或收集器。 | 
| Snowflake:关注 Snowpark Checkpoints 视图 | 将专注点转移到面板 SNOWPARK CHECKPOINTS。 | 
| Snowflake:打开检查点时间轴 | 显示检查点执行的时间轴。 | 
| Snowflake:从当前文件运行所有检查点 | 运行当前文件中所有已启用的检查点。 | 
| Snowflake:运行工作区中的所有检查点 | 从工作区运行所有已启用的检查点。 | 
| Snowflake:显示所有 Snowpark Checkpoints 结果 | 显示包含所有检查点结果的选项卡。 | 
警告¶
- Duplicate: In a collection project, if two checkpoints have the same name, this warning is displayed: "Another checkpoint with an identical name has been detected and will be overwritten." - Validation projects can have multiple checkpoints with the same name, so no warning is displayed. 
- Wrong type: If you add a checkpoint with a different type than the project type, it is underlined, and this error message is displayed: "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 is displayed: "Invalid checkpoint name. Checkpoint names must start with a letter and can only contain letters, numbers, hyphens, and underscores".