ALTER STREAMLIT

既存のStreamlitオブジェクトのプロパティを変更します。

こちらもご参照ください。

CREATE STREAMLIT, SHOW STREAMLITS, DESCRIBE STREAMLIT, DROP STREAMLIT

構文

ALTER STREAMLIT [ IF EXISTS ] <name> SET
  [ MAIN_FILE = '<filename>']
  [ QUERY_WAREHOUSE = <warehouse_name> ]
  [ RUNTIME_NAME = '<runtime_name>' ]
  [ COMPUTE_POOL = <compute_pool_name> ]
  [ COMMENT = '<string_literal>']
  [ TITLE = '<app_title>' ]
  [ IMPORTS = ( '<stage_path_and_file_name_to_read>' [ , ... ] ) ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
  [ SECRETS = ( '<snowflake_secret_name>' = <snowflake_secret> [ , ... ] ) ]

ALTER STREAMLIT [ IF EXISTS ] <name> RENAME TO <new_name>

ALTER STREAMLIT <name> COMMIT

ALTER STREAMLIT <name> PUSH [ TO <git_branch_uri> ]
  [
    {
      GIT_CREDENTIALS = <snowflake_secret>
      | USERNAME = <git_username> PASSWORD = <git_password>
    }
    NAME = <git_author_name>
    EMAIL = <git_author_email>
  ]
  [ COMMENT = <git_push_comment> ]

ALTER STREAMLIT <name> ABORT

ALTER STREAMLIT <name> PULL

ALTER STREAMLIT <name> ADD LIVE VERSION FROM LAST
Copy

For Streamlit objects created with ROOT_LOCATION, only the following syntax is supported:

重要

ROOT_LOCATION is a legacy parameter and may be deprecated in a future release. For Streamlit apps created using ROOT_LOCATION, multi-file editing and Git integration are not supported.

ALTER STREAMLIT [ IF EXISTS ] <name> SET
  [ ROOT_LOCATION = '<stage_path_and_root_directory>' ]
  [ MAIN_FILE = '<path_to_main_file>']
  [ QUERY_WAREHOUSE = <warehouse_name> ]
  [ COMMENT = '<string_literal>']
  [ TITLE = '<app_title>' ]
  [ IMPORTS = ( '<stage_path_and_file_name_to_read>' [ , ... ] ) ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]

ALTER STREAMLIT [ IF EXISTS ] <name> RENAME TO <new_name>
Copy

パラメーター

name

Streamlitオブジェクトの識別子。識別子にスペースまたは特殊文字が含まれる場合は、文字列全体を二重引用符で囲む必要があります。二重引用符で囲まれた識別子も大文字と小文字が区別されます。

SET ...

Streamlitオブジェクトに設定するプロパティを指定します。

MAIN_FILE = 'filename'

Specifies the Streamlit entrypoint file. The requirements depend on the runtime type:

  • Warehouse runtimes: The file must be in the root of the source directory specified in FROM. Only a filename is allowed, not a path.

  • Container runtimes: The file can be in the root or a subdirectory. You can specify a relative path from the root of the source directory, like 'subdir/my_app.py'.

    If your app was created with ROOT_LOCATION instead of FROM, then MAIN_FILE can be a path relative to ROOT_LOCATION even though ROOT_LOCATION only supports warehouse runtimes.

QUERY_WAREHOUSE = warehouse_name

Specifies the warehouse used by the Streamlit app. The behavior depends on the runtime type:

  • Warehouse runtimes: Specifies the warehouse to run the app code and execute SQL queries. This is the code warehouse. It's recommended to manually switch to a different warehouse within your app code for queries.

  • Container runtimes: Specifies the warehouse to execute SQL queries issued by the app. The app code runs on the compute pool specified by COMPUTE_POOL.

RUNTIME_NAME = 'runtime_name'

Specifies the runtime environment for the Streamlit app. Use this to change the runtime from warehouse to container, from container to warehouse, or from one version to another. Runtime names follow the pattern SYSTEM$ST_<type>_RUNTIME_PY<version>.

  • Warehouse runtimes: Run the app in a virtual warehouse. Each viewer gets a personal instance of the app. The following warehouse runtimes are valid:

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_9

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_10

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_11

  • Container runtimes: Run the app in a Snowpark Container Services compute pool. All viewers share a single, long-running instance of the app. The following container runtimes are valid:

    • SYSTEM$ST_CONTAINER_RUNTIME_PY3_11

重要

When changing from a warehouse runtime to a container runtime, you must also set the COMPUTE_POOL parameter as appropriate. Container runtimes require a compute pool.

COMPUTE_POOL = compute_pool_name

Specifies the compute pool where the Streamlit app runs. This parameter is required when using a container runtime and is ignored for warehouse runtimes.

COMMENT = 'string_literal'

Streamlitオブジェクトのコメントを追加するか、既存のコメントを上書きします。

TITLE = 'app_title'

Snowsight に表示するStreamlitアプリのタイトルを追加します。

IMPORTS = ( 'stage_path_and_file_name_to_read' [ , ... ] )

The location (stage), path, and name of the file(s) to import. This only applies to warehouse runtimes and is ignored for container runtimes.

EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )

Streamlitアプリケーションコードが外部ネットワークにアクセスするために必要な 外部アクセス統合 の名前。

For container runtimes, external access integrations are required to install packages from external package indexes like PyPI. For all runtime types, external access integrations enable the app to make outbound network requests.

SECRETS = ( 'snowflake_secret_name' = snowflake_secret [ , ... ] )

Maps Snowflake secrets to secret names that can be referenced in the Streamlit app code. The secret name (left side) is how you reference the secret in your code, and the secret object (right side) is the identifier of the Snowflake secret.

For example: SECRETS = ('api_key' = my_database.my_schema.my_secret)

Secrets are only available in warehouse runtimes through the _snowflake module and must be associated with an external access integration in EXTERNAL_ACCESS_INTEGRATIONS. In container runtimes, this parameter isn't supported and you must create SQL functions to access secrets instead. For more information, see Manage secrets and configure your Streamlit app.

ROOT_LOCATION = 'stage_path_and_root_directory'

Specifies the root stage name and prefix containing the Streamlit Python files, media files, and environment.yml file. This parameter must point to a single directory inside a named internal stage.

RENAME TO new_name

Specifies the new identifier for the Streamlit object. The identifier must be unique for the schema where the object was created.

識別子の詳細については、 識別子の要件 をご参照ください。

COMMIT

LIVE バージョンで保留中の編集を新しい LAST バージョンにコミットします。コミット直後、 LIVE バージョンは LAST バージョンと同一になります。

PUSH

コミットされた最新の変更をGitリポジトリにプッシュします。TO git_branch_uri が指定されていない場合は、ベースバージョンに保存されているブランチを使用します。

If the base version is not based on a Git branch, this throws an error.

TO git_branch_uri

コミットした変更を指定したブランチにプッシュします。

GIT_CREDENTIALS = snowflake_secret

リポジトリとの認証に使用する認証情報が含まれるSnowflakeシークレットを指定します。

USERNAME = git_username

Gitのユーザー名を指定します。

PASSWORD = git_password

Gitのパスワードを指定します。

NAME = git_author_name

使用するgit authorの名前を指定します。

EMAIL = git_author_email

git authorの名前として使用する有効なメールアドレスを指定します。

COMMENT = git_push_comment

git pushに含めるコメントを指定します。

ABORT

コミットされていない Snowsight で行われたすべての編集を含む、アプリの現在のライブバージョンを削除します。

PULL

最新の変更をプルします。プルする前に、現在のライブバージョンを中止する必要があります。

ADD LIVE VERSION FROM LAST

最後にコミットされたバージョンに基づいて、アプリの新しいライブバージョンを作成します。

Streamlitアプリの所有者が Snowsight でアプリを開いたときにライブバージョンが存在しない場合、このコマンドが自動的に実行されます。別のユーザーがアプリにアクセスしたときにライブバージョンが存在しない場合、エラーが返されます。

アクセス制御の要件

If your role does not own the objects in the following table, then your role must have the listed privileges on those objects:

権限

オブジェクト

Notes

OWNERSHIP

変更するStreamlitオブジェクト

USAGE

Warehouse used by the Streamlit app

This privilege is only required if you set a new value for QUERY_WAREHOUSE.

USAGE

Compute pool used by the Streamlit app

This privilege is only required if you set a new value for COMPUTE_POOL.

USAGE

External access integrations used by the Streamlit app

This privilege is only required if you set a new value for EXTERNAL_ACCESS_INTEGRATIONS.

USAGE

Secrets used by the Streamlit app

This privilege is only required if you set a new value for SECRETS.

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

指定された権限のセットを使用してカスタムロールを作成する手順については、 カスタムロールの作成 をご参照ください。

セキュリティ保護可能なオブジェクト に対して SQL アクションを実行するためのロールと権限付与に関する一般的な情報については、 アクセス制御の概要 をご参照ください。

使用上の注意

  • アプリのライブバージョンを削除した場合、ユーザーは以下のいずれかのアクションを実行するまでアプリにアクセスできません。

    • Streamlitオブジェクトに対して ALTER STREAMLIT...ADD LIVE VERSION FROM LAST を実行します。

    • アプリを所有するロールを使用して、 Snowsight でアプリにアクセスします。

  • If you run the ALTER STREAMLIT command while viewing a Streamlit app in Snowsight, the app reflects the changes differently depending on the runtime type:

    • Warehouse runtime: The app doesn't reflect the changes until you select Run.

    • Container runtime: The app reflects the changes immediately when you next interact with the app.

    変更をアプリに反映させる場合は、アプリをリロードするか再起動する必要があります。

  • When migrating from warehouse runtime to container runtime:

    • You must set both RUNTIME_NAME and COMPUTE_POOL.

    • Your app must use Python 3.11 and Streamlit 1.49 or later.

    • Ensure your app code is thread-safe and optimized for concurrent viewers.

    • Replace get_active_session() with st.connection("snowflake").

    • Replace _snowflake module with native Python equivalents.

    For a complete migration checklist, see Migrating between runtime environments.

  • メタデータについて:

    注意

    Snowflakeサービスを使用する場合、お客様は、個人データ(ユーザーオブジェクト向け以外)、機密データ、輸出管理データ、またはその他の規制されたデータがメタデータとして入力されていないことを確認する必要があります。詳細については、 Snowflakeのメタデータフィールド をご参照ください。

Examples

Change the query warehouse

To change the warehouse used by a Streamlit app, run the ALTER STREAMLIT command as shown in the following example:

ALTER STREAMLIT my_app
  SET QUERY_WAREHOUSE = new_warehouse;
Copy

Migrate from a warehouse runtime to a container runtime

To migrate a Streamlit app from warehouse runtime to container runtime, run the ALTER STREAMLIT command as shown in the following example:

ALTER STREAMLIT my_app SET
  RUNTIME_NAME = 'SYSTEM$ST_CONTAINER_RUNTIME_PY3_11'
  COMPUTE_POOL = my_compute_pool
  EXTERNAL_ACCESS_INTEGRATIONS = (pypi_access_integration);
Copy

Container runtimes require an external access integration to install packages from external package indexes like PyPI. Otherwise, they can only use the default, pre-installed packages. For more information, see Manage dependencies for your Streamlit app.

Add secrets to an existing warehouse-runtime app

To add secrets to an existing warehouse-runtime Streamlit app, run the ALTER STREAMLIT command as shown in the following example:

ALTER STREAMLIT my_app SET
  EXTERNAL_ACCESS_INTEGRATIONS = (my_access_integration)
  SECRETS = ('api_key' = my_database.my_schema.my_api_secret);
Copy

Secrets are only available in warehouse runtimes and must be associated with an external access integration. Container-runtime Streamlit apps must use SQL functions to access secrets. For more information, see Manage secrets and configure your Streamlit app.

Rename a Streamlit app

To rename a Streamlit app, run the ALTER STREAMLIT command as shown in the following example:

ALTER STREAMLIT old_app_name
  RENAME TO new_app_name;
Copy