将项目定义文件从版本 1.x 迁移到版本 2.0¶
要将版本 1.x 项目定义文件转换为版本 2 格式,请执行以下操作:
- Go to your project directory that contains the version 1.x
snowflake.ymlfile. - Enter the
snow helpers v1-to-v2command.-
如果版本 1.x 文件转换成功,则该命令将显示一条类似于以下内容的消息:
-
如果您的项目定义文件已经更新到版本 2,则该命令会显示以下消息:
-
- If you try to convert a project file that contains a snowflake.local.yml file, without using the
--[no]-migrate-local-overridesoption, the command generates an error similar to the following:
If you try to convert a project file that contains templates, without using the
--accept-templatesoption, the command generates an error similar to the following:If you convert a project definition file that contains templates, and use the
--accept-templatesoption, the command converts the file and displays a warning message similar to the following:
转换 Native App 项目¶
This section shows an example from a V1 to V2 conversion of a Snowflake Native App project, lists the changes in property names, and offers some tips to help with migration.
Snowflake Native App conversion example¶
Native Apps project conversion example
| V1 project file | V2 project file |
|---|---|
Native App 项目定义从 V1 到 V2 的属性变更¶
Native App project definition V1 to V2 property changes
| V1 property | V2 property |
|---|---|
native_app.name | No equivalent. Use a template variable to port, if required. |
native_app.deploy_root | <package entity>.deploy_root |
native_app.generated_root | <package entity>.generated_root |
native_app.bundle_root | <package entity>.bundle_root |
native_app.source_stage | <package entity>.source_stage |
native_app.scratch_stage | <package entity>.scratch_stage |
native_app.artifacts | <package entity>.artifacts |
native_app.application.debug | <application entity>.debug |
native_app.application.name | <application entity>.identifier |
native_app.application.post_deploy | <application entity>.meta.post_deploy (see above notes) |
native_app.application.role | <application entity>.meta.role |
native_app.application.warehouse | <application entity>.meta.warehouse |
native_app.package.distribution | <package entity>.distribution |
native_app.package.name | <package entity>.identifier |
native_app.package.post_deploy | <package entity>.meta.post_deploy (see above notes) |
native_app.package.role | <package entity>.meta.role |
native_app.package.scripts | <package entity>.meta.post_deploy (see above notes) |
native_app.package.warehouse | <package entity>.meta.warehouse |
迁移技巧
- When migrating Snowflake Native App package scripts, the
v1-to-v2command converts them topackage post-deployhooks and replaces{{package_name}}in the package script file with the equivalent template expression. - When migrating existing template expressions,
ctx.native_app,ctx.streamlit, andctx.snowparkvariables are no longer accepted. Thev1-to-v2command with equivalent template expressions that reference the specific entity name instead. For example,ctx.native_app.package.namecould be replaced withctx.entities.pkg.identifierif the package was migrated to an entity namedpkgin thesnowflake.ymlfile.
转换 Streamlit 项目¶
本节显示了 Streamlit 项目从 V1 到 V2 转换的示例,列出了属性名称的变更,并提供了一些有助于迁移的技巧。
Streamlit 转换示例¶
Streamlit project conversion example
| V1 project file | V2 project file |
|---|---|
Streamlit 项目定义从 V1 到 V2 的属性变更¶
Streamlit project definition V1 to V2 property changes
| V1 property | V2 property |
|---|---|
streamlit.name | <streamlit entity>.identifier.name |
streamlit.schema | <streamlit entity>.identifier.schema |
streamlit.database | <streamlit entity>.identifier.database |
streamlit.comment | <streamlit entity>.comment |
streamlit.title | <streamlit entity>.title |
streamlit.query_warehouse | <streamlit entity>.query_warehouse |
streamlit.main_file | <streamlit entity>.main_file and <streamlit entity>.artifacts |
streamlit.stage | <streamlit entity>.stage |
streamlit.env_file | <streamlit entity>.artifacts |
streamlit.pages_dir | <streamlit entity>.pages_dir and <streamlit entity>.artifacts |
streamlit.additional_source_files | <streamlit entity>.artifacts |
Streamlit 迁移技巧¶
无。
转换 Snowpark 项目¶
本节显示了 Snowpark 项目从 V1 到 V2 转换的示例,列出了属性名称的变更,并提供了一些有助于迁移的技巧。
Snowpark 转换示例¶
Snowpark project conversion example
| V1 project file | V2 project file |
|---|---|
Snowpark 项目定义从 V1 到 V2 的属性变更¶
Snowpark project definition V1 to V2 property changes
| V1 property | V2 property |
|---|---|
snowpark.project_name | <function or procedure entity>.artifacts.dest for each function and/or procedure migrated from the project. See above notes regarding Snowpark migration. Each function or procedure should declare an artifact with dest defined as the snowpark.project_name value, and src defined as the snowpark.src value. Use of a mixin is recommended. |
snowpark.stage_name | <function or procedure entity>.stage for each function and/or procedure migrated from the project. |
snowpark.src | <function or procedure entity>.artifacts.src for each function and/or procedure migrated from the project. (see snowpark.project_name above) |
snowpark.functions (list) | <function entities> (top-level) |
snowpark.procedures (list) | <procedure entities> (top-level) |
Snowpark function and procedure definition V1 to V2 property changes
| V1 property | V2 property |
|---|---|
name | identifier.name |
schema | identifier.schema |
database | identifier.database |
handler | handler |
returns | returns |
signature | signature |
runtime | runtime |
external_access_integrations | external_access_integrations |
secrets | secrets |
imports | imports |
execute_as_caller | execute_as_caller (only for procedures) |
Snowpark 迁移技巧¶
- When migrating Snowpark projects, each function (from the
snowpark.functionsarray) or procedure (from thesnowpark.proceduresarray) maps to a top-level entity. - All top-level Snowpark project properties (e.g.
src) are now defined for each function and procedure. To reduce duplication, Snowflake recommends that you declare amixinand include it in each of the migrated function and procedure entities.