Snowpark Migration Accelerator:引导教程设置¶
本指南提供了 Snowpark Migration Accelerator (SMA) 的实践经验。通过真实示例,您将学习如何评估代码和解释评估结果,从而清楚地了解该工具的功能。
材料¶
要完成本教程,您将需要:
一台安装了 Snowpark Migration Accelerator (SMA) 软件的计算机
在同一台计算机上访问示例代码文件
首先,您需要在计算机上安装:
Snowpark Migration Accelerator (SMA) 工具
代码示例
让我们来看看如何获得这些基本资源。
SMA 应用程序¶
Snowpark Migration Accelerator (SMA) 帮助开发者将其 PySpark 和 Spark Scala 应用程序转换为在 Snowflake 上运行。它会自动检测您的 Python 或 Scala 代码中的 Spark API 调用,并将其转换为等效的 Snowpark API 调用。本指南将通过分析示例 Spark 代码并展示其如何为迁移项目提供帮助,演示基本的 SMA 功能。
在初始评估阶段,Snowpark Migration Accelerator (SMA) 会检查您的源代码并构建一个详细的模型,以捕获代码中的所有功能。基于此分析,SMA 创建了多份报告,其中包括一份详细的评估报告,我们将在本引导教程中对其进行审查。这些报告可帮助您了解代码迁移到 Snowpark 的准备情况,并估算过渡所需的工作量。在继续完成本实验的过程中,我们将更详细地研究这些发现。
下载和安装¶
To begin an assessment with the Snowpark Migration Accelerator (SMA), you only need to complete the installation process. While Snowflake provides optional helpful training on using the SMA (https://learn.snowflake.com/en/courses/spark-to-snowpark-sma/), you can proceed without it. No special access codes are needed. Simply:
Visit our Download and Access section
Follow our Installation instructions to set up the application on your computer
示例代码库¶
本指南使用 Python 代码示例来演示迁移过程。我们从第三方 Git 存储库中选择了两个公开的示例代码库作为无偏真实示例。您可以通过以下方式访问这些代码库:
PySpark Data Engineering Examples: https://github.com/spark-examples/pyspark-examples (https://github.com/spark-examples/pyspark-examples)
Apache Spark Machine Learning Examples: https://github.com/apache/spark/tree/master/examples/src/main/python (https://github.com/apache/spark/tree/master/examples/src/main/python)
要使用 Snowpark Migration Accelerator (SMA) 分析代码库,请执行以下步骤:
Download the codebases as zip files from GitHub. You can find instructions on how to do this in the GitHub documentation (https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives).
在计算机上为每个代码库创建单独的文件夹。
将每个 zip 文件解压缩到其指定文件夹,如下图所示:
These sample codebases demonstrate how SMA evaluates Spark API references to calculate the Spark API Readiness Score. Let's look at two scenarios:
一个获得高分的代码库,表明它与 Snowpark 高度兼容并准备迁移
一个得分较低的代码库,表明在迁移之前需要进行额外审查,可能还需修改
尽管就绪度分数提供了有价值的参考,但它不应是规划迁移时唯一考虑的因素。无论是高分还是低分评估,都必须对各个方面进行全面评估,以确保成功迁移。
After unzipping the directories, SMA will analyze only files that use supported code formats and notebook formats. These files are checked for references to Spark API and other Third Party APIs. To see which file types are supported, please check the list here.
本引导教程剩下的部分将分析这两个代码库的执行方式。
支持¶
For help with installation or to get access to the code, please email sma-support@snowflake.com.
将代码库下载并解压缩到单独的目录后,您可以:
Move on to running the tool
Review the code preparation notes