设置适用于使用 Snowpark Checkpoints 的 IDE

适用于 Visual Studio Code 的 Snowflake 扩展程序 为 Snowpark Checkpoints 库提供支持,以增强使用框架的体验。它使您能够对插入到代码中的 collectvalidate 语句进行细粒度控制,并查看转换后的代码的行为等价断言的状态。

启用 Snowpark Checkpoints

  • 要启用 Snowpark Checkpoints,请转到 Snowflake 的扩展设置并检查 Snowpark Checkpoints: Enabled

已启用的检查点

视图

如前所述,通过将 Snowpark Checkpoints 属性设置为 Enabled,将在名为 SNOWPARK CHECKPOINTS 的扩展中打开一个新选项卡。该选项卡显示工作区中的所有检查点,并能够执行多个操作,例如启用/禁用全部或单个检查点、清理文件中的全部检查点,并通过双击每个检查点导航到定义检查点的文件和代码行。

切换所有检查点

  • To enable or disable all checkpoints, select this control in the upper-right corner of the Snowpark Checkpoints tab:

切换检查点

已启用的检查点:

切换检查点

禁用检查点会导致它在运行时被跳过。

禁用检查点

删除检查点

  • 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.

在文件中插入检查点

  • 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 命令

添加检查点

已添加收集器/验证器:

收集器和验证器检查点

运行单个检查点

  • To run a single checkpoint, select the code lens option displayed above the checkpoint:

运行单个检查点

通过点击每个检查点上方显示的代码透视表选项,可以运行单个检查点。运行单个检查点将打开一个显示进度的输出控制台,完成后将调出结果视图。即使在合同文件中禁用了该检查点,但在执行时它也会被启用。

如果未在合同文件中声明入口点,将显示错误消息:Entry point not found for the checkpoint.

未找到入口点

在文件中运行所有已启用的 Snowpark Checkpoints

  • 在每个文件的右上角,将显示 Run all checkpoints from the current file 按钮。

运行所有检查点

An output channel displays the progress:

检查点进度

时间轴视图

显示检查点执行结果的时间轴。

时间轴视图

命令

Snowpark Checkpoints 可以使用以下命令。要使用这些命令,请在命令面板中输入 Snowflake: [command name]

命令

描述

Snowflake:切换检查点

切换所有检查点的已启用属性。

Snowflake:Snowpark Checkpoints 项目初始化

触发项目初始化,如果不存在合同文件,则创建合同文件。如果存在,将显示一个弹出窗口,询问您是否要将检查点加载到合同文件中。

Snowflake:清除所有检查点

从工作区中的所有文件中删除所有检查点。

Snowflake:恢复所有检查点

恢复之前从已存在的合同文件中删除的检查点。

Snowflake:添加验证/收集检查点

在光标位置添加带有其强制参数的验证器或收集器。

Snowflake:关注 Snowpark Checkpoints 视图

将专注点转移到面板 SNOWPARK CHECKPOINTS

Snowflake:打开检查点时间轴

显示检查点执行的时间轴。

Snowflake:从当前文件运行所有检查点

运行当前文件中所有已启用的检查点。

Snowflake:运行工作区中的所有检查点

从工作区运行所有已启用的检查点。

Snowflake:显示所有 Snowpark Checkpoints 结果

显示包含所有检查点结果的选项卡。

警告

  • 重复:在集合项目中,如果分配了两个同名检查点,则会显示警告:“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.

  • 错误类型:如果在项目中添加了与项目类型不同类型的检查点,系统将会显示以下错误消息 “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.Checkpoint names must start with a letter and can only contain letters, numbers, hyphens, and underscores”