Snowpark Migration Accelerator:SMA CLI 演练教程¶
The Snowpark Migration Accelerator (SMA) helps developers migrate their Python or Scala Spark code to Snowpark. It analyzes your code and:
评估与 Snowpark 的兼容性
自动将兼容的 Spark API 调用转换为 Snowpark API
识别无法自动转换的代码
创建从脚本和笔记本导入的第三方库清单
生成可编辑的兼容性报告,对比 Spark 和 Snowpark 代码
Snowflake 发布了适用于 Snowpark Migration Accelerator (SMA) 的命令行界面 (CLI)。本指南将演示如何单独使用 CLI 以及如何在脚本中使用它。
使用 CLI¶
You can download the Command Line Interface (CLI) from the Download and Access section. Select the version that matches your operating system. You can store the CLI in any accessible location on your machine or container.
备注
NOTE:虽然本次演练使用的是来自 Mac 计算机的屏幕截图,但 Windows 和 Linux 用户的过程与之类似。
下载包文件(zip 或 .tar 格式)后,提取其内容。命令行界面 (CLI) 工具位于解压缩后文件的“orchestrator”文件夹中。
在安装文件夹中打开终端或命令提示符,然后运行以下命令检查其版本来验证 CLI 安装:
./sma --version
您会看到如下所示的结果:
The SMA Command Line Interface (CLI) is a local application that runs on your computer, similar to the SMA desktop application. To analyze your code files using the SMA CLI, these files must be stored on your local machine where the CLI can access them. The CLI supports the same file types as the regular SMA application. For a complete list of supported file types, refer to the supported filetypes in the SMA documentation.
备注
NOTE: To test the CLI functionality, you can use the sample codebase provided in the Assessment section or refer to the Conversion walkthroughs in the SMA documentation.
SMA 文档包含 CLI 实参的完整列表。接下来让我们来探讨本部分中最重要的内容。
The SMA CLI runs in Conversion mode by default, rather than Assessment mode. To run the CLI in assessment mode, use the -a argument. For conversion operations, you'll need a valid access code. To verify if you have a valid access code, use the following command:
要运行转换,您需要提供以下信息:
输入目录(必填)
输出目录(必填)
如果您之前未创建过项目文件,则还需提供:
用户邮箱
组织名称
项目名称
首次设置这些参数后,以后运行转换时只需指定输入目录和输出目录即可。
此屏幕显示您的执行设置摘要,并提示您确认是否继续。
要跳过确认提示,请添加 --yes 或 -y 参数。当使用自动脚本运行 CLI 时,这一点尤其重要。
该工具在执行过程中会提供详细的进度信息。
While the tool is running, it will continuously print output to the screen. When the process is complete, you will see the prompt again. The tool generates detailed output that includes all processes, issues, and completed or failed steps. You don't need to read through all of this information while it's running, as you can review it later in the Logs output folder.
查看输出¶
SMACLI 生成的输出与 SMA 应用程序相同。运行该工具时,它会在您指定的输出目录中创建三个文件夹:
For detailed guidance on working with code that has been converted by the Snowpark Migration Accelerator (SMA), refer to the conversion walkthrough.
以编程方式运行 CLI¶
即将推出!SMA 团队将提供一个脚本,使您能够跨多个目录自动运行 SMA 命令行界面 (CLI)。
Try out the Command Line Interface (CLI) today. If you need help or have questions, contact the Snowpark Migration Accelerator team at sma-support@snowflake.com.