バージョン1.xから2.0へのプロジェクト定義ファイルの移行¶
バージョン1.xのプロジェクト定義ファイルをバージョン2フォーマットに変換するには、以下のようにします:
バージョン1.xの
snowflake.yml
ファイルを含むプロジェクト・ディレクトリに移動します。snow helpers v1-to-v2
コマンドを入力します。バージョン1.xのファイル変換が成功すると、コマンドは以下のようなメッセージを表示します:
cd <project-directory> snow helpers v1-to-v2
Project definition migrated to version 2.
プロジェクト定義ファイルがすでにバージョン2に更新されている場合、コマンドは以下のメッセージを表示します:
cd <project-directory> snow helpers v1-to-v2
Project definition is already at version 2.
If you try to convert a project file that contains a
snowflake.local.yml
file, without using the--[no]-migrate-local-overrides
option, the command generates an error similar to the following:
--accept-templates
オプションを使用せずに、テンプレートを含むプロジェクト・ファイルを変換しようとすると、コマンドは次のようなエラーを生成します:cd <project-directory> snow helpers v1-to-v2+- Error-------------------------------------------------------------------+ | snowflake.local.yml file detected, please specify | | --migrate-local-overrides to include or --no-migrate-local-overrides to | | exclude its values. | +--------------------------------------------------------------------------+テンプレートを含むプロジェクト定義ファイルを変換するときに:codenowrap:
--accept-templates
オプションを使用すると、コマンドはファイルを変換し、次のような警告メッセージを表示します:cd <project-directory> snow helpers v1-to-v2WARNING snowflake.cli._plugins.workspace.commands:commands.py:60 Your V1 definition contains templates. We cannot guarantee the correctness of the migration. Project definition migrated to version 2
Native Appsのプロジェクトを変換する¶
このセクションでは、 Snowflake Native App プロジェクトの V1 から V2 への変換の例を示し、プロパティ名の変更点を列挙し、移行に役立ついくつかのヒントを示します。
Snowflake Native App 変換例¶
V1プロジェクトファイル |
V2プロジェクトファイル |
---|---|
definition_version: 1
native_app:
name: myapp
source_stage: app_src.stage
artifacts:
- src: app/*
dest: ./
processors:
- native app setup
- name: templates
properties:
foo: bar
package:
role: pkg_role
distribution: external
application:
name: myapp_app
warehouse: app_wh
|
definition_version: 2
entities:
pkg:
type: application package
meta:
role: pkg_role
identifier: <% fn.concat_ids('myapp', '_pkg_', fn.sanitize_id(fn.get_username('unknown_user')) | lower) %>
manifest: app/manifest.yml
artifacts:
- src: app/*
dest: ./
processors:
- name: native app setup
- name: templates
properties:
foo: bar
stage: app_src.stage
app:
meta:
warehouse: app_wh
identifier: myapp_app
type: application
from:
target: pkg
|
Native Appsのプロジェクト定義 V1 から V2 へのプロパティ変更¶
V1プロパティ |
V2プロパティ |
---|---|
|
同等のものはありません。必要であれば、テンプレート変数を使って移植します。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
移行のヒント¶
Snowflake Native App のパッケージスクリプトを移行する場合、
v1-to-v2
コマンドは、それらを:codenowrap:package post-deploy
フックに変換し、パッケージスクリプトファイル内の:codenowrap:{{package_name}}
を同等のテンプレート式に置き換えます。既存のテンプレート式を移行する場合、
ctx.native_app
、ctx.streamlit
、および:codenowrap:ctx.snowpark
変数は受け付けられなくなります。v1-to-v2
コマンドの代わりに、特定のエンティティ名を参照する同等のテンプレート式。例えば、ctx.native_app.package.name
は、パッケージがsnowflake.yml
ファイルの:codenowrap:pkg
という名前のエンティティに移行された場合、ctx.entities.pkg.identifier
に置き換えることができます。
Streamlitプロジェクトの変換¶
このセクションでは、StreamlitプロジェクトのV1からV2への変換例を示し、プロパティ名の変更点を列挙し、移行に役立ついくつかのヒントを提供します。
Streamlit変換例¶
V1プロジェクトファイル |
V2プロジェクトファイル |
---|---|
definition_version: 1
streamlit:
name: test_streamlit
stage: streamlit
query_warehouse: test_warehouse
main_file: "streamlit_app.py"
title: "My Fancy Streamlit"
|
definition_version: 2
entities:
test_streamlit:
identifier:
name: test_streamlit
type: streamlit
title: My Fancy Streamlit
query_warehouse: test_warehouse
main_file: streamlit_app.py
pages_dir: None
stage: streamlit
artifacts:
- streamlit_app.py
|
Streamlit プロジェクト定義 V1 から V2 へのプロパティ変更¶
V1プロパティ |
V2プロパティ |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Streamlit移行のヒント¶
なし。
Snowparkプロジェクトを変換する¶
このセクションでは、SnowparkプロジェクトのV1からV2への変換の例を示し、プロパティ名の変更点を列挙し、移行に役立ついくつかのヒントを提供します。
Snowparkの変換例¶
V1プロジェクトファイル |
V2プロジェクトファイル |
---|---|
definition_version: 1
snowpark:
project_name: "my_snowpark_project"
stage_name: "dev_deployment"
src: "app/"
functions:
- name: func1
handler: "app.func1_handler"
signature:
- name: "a"
type: "string"
default: "default value"
- name: "b"
type: "variant"
returns: string
runtime: 3.10
procedures:
- name: procedureName
handler: "hello"
signature:
- name: "name"
type: "string"
returns: string
|
definition_version: 2
entities:
procedureName:
imports: []
external_access_integrations: []
secrets: {}
meta:
use_mixins:
- snowpark_shared
identifier:
name: procedureName
handler: hello
returns: string
signature:
- name: name
type: string
stage: dev_deployment
artifacts:
- src: app
dest: my_snowpark_project
type: procedure
execute_as_caller: false
func1:
imports: []
external_access_integrations: []
secrets: {}
meta:
use_mixins:
- snowpark_shared
identifier:
name: func1
handler: app.func1_handler
returns: string
signature:
- name: a
type: string
default: default value
- name: b
type: variant
runtime: '3.10'
stage: dev_deployment
artifacts:
- src: app
dest: my_snowpark_project
type: function
mixins:
snowpark_shared:
stage: dev_deployment
artifacts:
- src: app/
dest: my_snowpark_project
|
Snowparkプロジェクト定義 V1からV2へのプロパティ変更¶
V1プロパティ |
V2プロパティ |
---|---|
|
プロジェクトから移行された各関数またはプロシージャについての:codenowrap: |
|
プロジェクトから移行された各関数やプロシージャーについての:codenowrap: |
|
|
|
|
|
|
V1プロパティ |
V2プロパティ |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Snowpark移行のヒント¶
Snowparkプロジェクトを移行する場合、各関数(
snowpark.functions
配列から)または各プロシージャ(snowpark.procedures
配列から)はトップレベルのエンティティにマッピングされます。これで、すべてのトップレベルのSnowparkプロジェクトプロパティ(例:
src
)が、関数とプロシージャごとに定義されるようになりました。重複を減らすため、Snowflakeでは:codenowrap:mixin
を宣言し、移行した関数とプロシージャの各エンティティに含めることを推奨しています。