バージョン1.xから2.0へのプロジェクト定義ファイルの移行

バージョン1.xのプロジェクト定義ファイルをバージョン2フォーマットに変換するには、以下のようにします:

  1. バージョン1.xの snowflake.yml ファイルを含むプロジェクト・ディレクトリに移動します。

  2. snow helpers v1-to-v2 コマンドを入力します。

    • バージョン1.xのファイル変換が成功すると、コマンドは以下のようなメッセージを表示します:

      cd <project-directory>
      snow helpers v1-to-v2
      
      Copy
      Project definition migrated to version 2.
      
    • プロジェクト定義ファイルがすでにバージョン2に更新されている場合、コマンドは以下のメッセージを表示します:

      cd <project-directory>
      snow helpers v1-to-v2
      
      Copy
      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
    
    Copy
    +- 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-v2
    
    Copy
    WARNING  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 変換例

Native Appsのプロジェクト変換例

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
Copy
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
Copy

Native Appsのプロジェクト定義 V1 から V2 へのプロパティ変更

Native Appsのプロジェクト定義 V1 から V2 へのプロパティ変更

V1プロパティ

V2プロパティ

native_app.name

同等のものはありません。必要であれば、テンプレート変数を使って移植します。

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 (上記注をご参照ください)

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 (上記注をご参照ください)

native_app.package.role

<package entity>.meta.role

native_app.package.scripts

<package entity>.meta.post_deploy (上記注をご参照ください)

native_app.package.warehouse

<package entity>.meta.warehouse

移行のヒント

  • Snowflake Native App のパッケージスクリプトを移行する場合、v1-to-v2 コマンドは、それらを:codenowrap:package post-deploy フックに変換し、パッケージスクリプトファイル内の:codenowrap:{{package_name}} を同等のテンプレート式に置き換えます。

  • 既存のテンプレート式を移行する場合、ctx.native_appctx.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変換例

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"
Copy
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
Copy

Streamlit プロジェクト定義 V1 から V2 へのプロパティ変更

Streamlit プロジェクト定義 V1 から V2 へのプロパティ変更

V1プロパティ

V2プロパティ

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 と:codenowrap:<streamlit entity>.artifacts

streamlit.additional_source_files

<streamlit entity>.artifacts

Streamlit移行のヒント

なし。

Snowparkプロジェクトを変換する

このセクションでは、SnowparkプロジェクトのV1からV2への変換の例を示し、プロパティ名の変更点を列挙し、移行に役立ついくつかのヒントを提供します。

Snowparkの変換例

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
Copy
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
Copy

Snowparkプロジェクト定義 V1からV2へのプロパティ変更

Snowparkプロジェクト定義 V1からV2へのプロパティ変更

V1プロパティ

V2プロパティ

snowpark.project_name

プロジェクトから移行された各関数またはプロシージャについての:codenowrap:<function or procedure entity>.artifacts.dest。Snowparkの移行については、上記の注意事項をご参照ください。各関数またはプロシージャは、dest を:codenowrap:snowpark.project_name の値として定義し、src を:codenowrap:snowpark.src の値として定義したアーティファクトを宣言する必要があります。ミキシンの使用を推奨します。

snowpark.stage_name

プロジェクトから移行された各関数やプロシージャーについての:codenowrap:<function or procedure entity>.stage

snowpark.src

<function or procedure entity>.artifacts.src プロジェクトから移行された各関数またはプロシージャ。(snowpark.project_name above をご参照ください)

snowpark.functions (list)

<function entities> (top-level)

snowpark.procedures (list)

<procedure entities> (top-level)

Snowpark関数およびプロシージャの定義 V1 から V2 へのプロパティの変更

V1プロパティ

V2プロパティ

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移行のヒント

  • Snowparkプロジェクトを移行する場合、各関数(snowpark.functions 配列から)または各プロシージャ(snowpark.procedures 配列から)はトップレベルのエンティティにマッピングされます。

  • これで、すべてのトップレベルのSnowparkプロジェクトプロパティ(例:src)が、関数とプロシージャごとに定義されるようになりました。重複を減らすため、Snowflakeでは:codenowrap:mixin を宣言し、移行した関数とプロシージャの各エンティティに含めることを推奨しています。