CREATE STREAMLIT

Creates a new Streamlit object in Snowflake or replaces an existing Streamlit object in the same schema.

참고 항목:

SHOW STREAMLITS, DESCRIBE STREAMLIT, ALTER STREAMLIT, DROP STREAMLIT, UNDROP STREAMLIT

구문

CREATE [ OR REPLACE ] STREAMLIT [ IF NOT EXISTS ] <name>
  [ FROM <source_location> ]
  [ 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> [ , ... ] ) ]
Copy

다음 구문은 레거시입니다.

중요

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.

CREATE [ OR REPLACE ] STREAMLIT [ IF NOT EXISTS ] <name>
  ROOT_LOCATION = '<stage_path_and_root_directory>'
  MAIN_FILE = '<path_to_main_file_in_root_directory>'
  [ QUERY_WAREHOUSE = <warehouse_name> ]
  [ COMMENT = '<string_literal>' ]
  [ TITLE = '<app_title>' ]
  [ IMPORTS = ( '<stage_path_and_file_name_to_read>' [ , ... ] ) ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
Copy

필수 매개 변수

name

Specifies the identifier (i.e. name) for the Streamlit object. This identifier must be unique for the schema where the object is created.

In addition, the identifier must start with an alphabetic character and can’t contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g. "My object"). Identifiers enclosed in double quotes are also case-sensitive.

자세한 내용은 식별자 요구 사항 섹션을 참조하십시오.

선택적 매개 변수

FROM source_location

지정된 위치에서 앱 소스 파일을 복사합니다. 위치는 명명된 내부 스테이지 내에 있어야 합니다. 경로는 상대 경로이거나 정규화된 경로일 수 있습니다. 예를 들어 스테이지의 이름이 ``@streamlit_db.streamlit_schema.streamlit_stage``인 경우 유효한 소스 위치에는 다음이 포함될 수 있습니다.

  • 스테이지 루트에 대한 정규화된 경로: FROM '@streamlit_db.streamlit_schema.streamlit_stage'

  • 스테이지 루트에 대한 상대 경로: FROM '@streamlit_stage'

  • 스테이지 내의 하위 디렉터리에 대한 정규화된 경로 또는 상대 경로: FROM '@streamlit_db.streamlit_schema.streamlit_stage/subdir'

파일은 CREATE 명령이 실행될 때 한 번만 복사됩니다. 소스 위치에 대한 향후 변경 사항은 Streamlit 앱을 자동으로 업데이트하지 않습니다.

이 매개 변수를 지정하지 않으면 Snowflake는 streamlit_app.py 진입점 파일이 있는 기본 앱의 소스 파일을 복사합니다.

MAIN_FILE = 'filename'

Streamlit 진입점 파일을 지정합니다. 요구 사항은 런타임 유형에 따라 다릅니다.

  • 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 Runtime: 파일은 루트 또는 하위 디렉터리에 있을 수 있습니다. ``’subdir/my_app.py’``와 같은 소스 디렉터리의 루트에서 상대 경로를 지정할 수 있습니다.

If you are using ROOT_LOCATION instead of FROM, then MAIN_FILE can be a path relative to ROOT_LOCATION even though ROOT_LOCATION only supports warehouse runtimes.

DEFAULT: 'streamlit_app.py'

QUERY_WAREHOUSE = warehouse_name

Streamlit 앱에서 사용하는 웨어하우스를 지정합니다. 동작은 런타임 유형에 따라 다릅니다.

  • Warehouse Runtime: 앱 코드를 실행하고 SQL 쿼리를 실행할 웨어하우스를 지정합니다. 이는 코드 웨어하우스입니다. 쿼리를 위해 앱 코드 내에서 다른 웨어하우스로 수동으로 전환하는 것이 좋습니다.

  • Container Runtime: 앱에서 발행한 SQL 쿼리를 실행할 웨어하우스를 지정합니다. 앱 코드는 COMPUTE_POOL로 지정된 컴퓨팅 풀에서 실행됩니다.

DEFAULT: 값 없음

참고

이 매개 변수 없이 Streamlit 오브젝트를 생성할 수 있지만, 쿼리 웨어하우스를 지정할 때까지 앱이 실행되지 않습니다.

RUNTIME_NAME = 'runtime_name'

Streamlit 앱의 런타임 환경을 지정합니다. 런타임은 앱이 실행되는 위치와 방법을 결정합니다. 런타임 이름은 SYSTEM$ST_<type>_RUNTIME_PY<version> 패턴을 따릅니다.

  • Warehouse Runtime: 가상 웨어하우스에서 앱을 실행합니다. 각 뷰어는 앱의 개인 인스턴스를 받습니다. 유효한 Warehouse Runtime은 다음과 같습니다.

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_9

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_10

    • SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_11

  • Container Runtime: Snowpark Container Services 컴퓨팅 풀에서 앱을 실행합니다. 모든 뷰어는 앱의 장기 실행 단일 인스턴스를 공유합니다. 유효한 Container Runtime은 다음과 같습니다.

    • SYSTEM$ST_CONTAINER_RUNTIME_PY3_11

런타임은 기본적으로 최신 Warehouse Runtime으로 설정됩니다.

DEFAULT: SYSTEM$ST_WAREHOUSE_RUNTIME_PY3_11

COMPUTE_POOL = compute_pool_name

Streamlit 앱이 실행되는 컴퓨팅 풀을 지정합니다. 이 매개 변수는 Container Runtime을 사용할 때 필요하며 Warehouse Runtime에서는 무시됩니다.

DEFAULT: 값 없음

COMMENT = 'string_literal'

Streamlit 오브젝트에 대한 설명을 명시합니다.

DEFAULT: 값 없음

TITLE = 'app_title'

Specifies a title for the Streamlit object to display in Snowsight.

DEFAULT: CREATE STREAMLIT에 전달된 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.

DEFAULT: 값 없음

EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )

Streamlit 앱 코드가 외부 네트워크에 액세스하려면 필요한 외부 액세스 통합 의 이름입니다.

Container Runtime의 경우, PyPI과 같은 외부 패키지 인덱스에서 패키지를 설치하려면 외부 액세스 통합이 필요합니다. 모든 런타임 유형의 경우, 외부 액세스 통합을 통해 앱이 아웃바운드 네트워크 요청을 수행할 수 있습니다.

DEFAULT: 값 없음

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

Snowflake 시크릿을 Streamlit 앱 코드에서 참조할 수 있는 시크릿 이름으로 매핑합니다. 시크릿 이름(왼쪽)은 코드에서 시크릿을 참조하는 방법이며, 시크릿 오브젝트(오른쪽)는 Snowflake 시크릿의 식별자입니다.

예: SECRETS = ('api_key' = my_database.my_schema.my_secret)

시크릿은 _snowflake 모듈을 통해 Warehouse Runtime에서만 사용할 수 있으며, EXTERNAL_ACCESS_INTEGRATIONS의 외부 액세스 통합과 연결되어야 합니다. Container Runtime에서는 이 매개 변수가 지원되지 않으므로 대신 시크릿에 액세스하려면 SQL 함수를 생성해야 합니다. 자세한 내용은 시크릿 관리 및 Streamlit 앱 구성하기 섹션을 참조하십시오.

DEFAULT: 값 없음

ROOT_LOCATION = 'stage_path_and_root_directory'

Specifies the path to the named stage containing the Streamlit Python files, media files, and the environment.yml file, for example:

ROOT_LOCATION = '@streamlit_db.streamlit_schema.streamlit_stage'
Copy

이 예에서 Streamlit 파일은 streamlit_db 라는 데이터베이스와 streamlit_schema 라는 스키마 내의 streamlit_stage 로 명명된 스테이지에 있습니다.

참고

  • 이 매개 변수는 명명된 내부 스테이지 내의 단일 디렉터리를 가리켜야 합니다.

  • Streamlit in Snowflake 에 대한 외부 스테이지는 지원되지 않습니다.

  • Snowflake Native App Framework 내에서 Streamlit 애플리케이션 오브젝트를 만들거나 바꾸는 경우 ROOT_LOCATION = 'stage_path_and_root_directory' 가 아닌 FROM 'relative_path_from_stage_root_directory' 를 사용하십시오.

액세스 제어 요구 사항

역할이 다음 테이블의 오브젝트를 소유하지 않는 경우 역할에 해당 오브젝트에 대한 나열된 :ref:`권한<label-access_control_overview_privileges>`이 있어야 합니다.

권한

오브젝트

Notes

CREATE STREAMLIT

Schema where you create the Streamlit object

READ

Streamlit 앱 소스 파일을 복사하는 스테이지

USAGE

Streamlit 앱에서 사용하는 웨어하우스

USAGE

Streamlit 앱에서 사용하는 컴퓨팅 풀

이 권한은 앱이 Container Runtime을 사용하는 경우에만 필요합니다.

USAGE

Streamlit 앱에서 사용하는 외부 액세스 통합

이 권한은 앱이 외부 액세스 통합을 사용하는 경우에만 필요합니다. Container Runtime의 경우, PyPI과 같은 외부 패키지 인덱스에서 패키지를 설치하려면 이 권한이 필요합니다.

USAGE

Secrets used by the Streamlit app

이 권한은 앱이 시크릿을 사용하고 Warehouse Runtime에만 적용되는 경우에만 필요합니다.

CREATE STAGE

Schema where you create the Streamlit object

이 권한은 ROOT_LOCATION 매개 변수를 사용하여 Streamlit 오브젝트를 생성할 때만 필요합니다.

스키마의 오브젝트에 대한 작업을 수행하려면 상위 데이터베이스에 대한 하나 이상의 권한과 상위 스키마에 대한 하나 이상의 권한이 필요합니다.

지정된 권한 세트로 사용자 지정 역할을 만드는 방법에 대한 지침은 사용자 지정 역할 만들기 섹션을 참조하십시오.

보안 오브젝트 에 대해 SQL 작업을 수행하기 위한 역할과 권한 부여에 대한 일반적인 정보는 액세스 제어의 개요 섹션을 참조하십시오.

사용법 노트

  • 앱을 만든 후에는 초기화해야 합니다.

    중요

    CREATE STREAMLIT를 사용한 후 Streamlit 앱은 다음 작업 중 하나를 수행할 때까지 활성화되지 않습니다.

    • 새 Streamlit 오브젝트에 대해 ALTER STREAMLIT … ADD LIVE VERSION FROM LAST를 실행합니다.

    • 앱을 소유한 역할을 사용하여 Snowsight 에서 앱을 방문합니다.

  • Streamlit 오브젝트가 포함된 스키마 또는 데이터베이스를 복제할 때 Streamlit 오브젝트는 복제되지 않습니다.

  • Streamlit 애플리케이션에서 사용하는 패키지를 지정하려면 소스 파일에 종속성 파일을 포함합니다. 종속성 파일의 형식은 런타임 유형에 따라 다릅니다.

    • Warehouse Runtime: environment.yml 파일을 사용합니다.

    • Container Runtime: pyproject.toml 또는 requirements.txt 파일을 사용합니다.

    자세한 내용은 Streamlit 앱의 종속성 관리하기 섹션을 참조하십시오.

  • 메타데이터 관련:

    주의

    고객은 Snowflake 서비스를 사용할 때 개인 데이터(사용자 오브젝트 제외), 민감한 데이터, 수출 통제 대상 데이터 또는 기타 규제 데이터가 메타데이터로 입력되지 않도록 해야 합니다. 자세한 내용은 Snowflake의 메타데이터 필드 섹션을 참조하십시오.

  • The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.

  • CREATE OR REPLACE <오브젝트> 문은 원자성입니다. 즉, 오브젝트가 바뀔 때 단일 트랜잭션으로 이전 오브젝트가 삭제되고 새 오브젝트가 생성됩니다.

기본 소스 파일로 Streamlit 앱 만들기

To create a container-runtime Streamlit app from built-in default files, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  RUNTIME_NAME = 'SYSTEM$ST_CONTAINER_RUNTIME_PY3_11'
  COMPUTE_POOL = my_compute_pool
  QUERY_WAREHOUSE = my_warehouse;
Copy

By default, apps use the latest warehouse runtime if RUNTIME_NAME isn’t specified. To create a warehouse-runtime Streamlit app from built-in default files, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  QUERY_WAREHOUSE = my_warehouse;
Copy

사용자 지정 소스 파일에서 Streamlit 앱 만들기

To create a container-runtime Streamlit app from custom source files, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  FROM @streamlit_db.streamlit_schema.streamlit_stage
  MAIN_FILE = 'streamlit_main.py'
  QUERY_WAREHOUSE = my_warehouse
  RUNTIME_NAME = 'SYSTEM$ST_CONTAINER_RUNTIME_PY3_11'
  COMPUTE_POOL = my_compute_pool;
Copy

To create a warehouse-runtime Streamlit app from custom source files, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  FROM @streamlit_db.streamlit_schema.streamlit_stage
  MAIN_FILE = 'streamlit_main.py'
  QUERY_WAREHOUSE = my_warehouse;
Copy

시크릿을 사용하여 Warehouse Runtime Streamlit 앱 만들기

To create a warehouse-runtime Streamlit app with secrets, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  FROM @streamlit_db.streamlit_schema.streamlit_stage
  MAIN_FILE = 'streamlit_main.py'
  QUERY_WAREHOUSE = my_warehouse
  SECRETS = ('api_key' = streamlit_db.streamlit_schema.my_api_secret);
Copy

Container Runtime Streamlit 앱이 시크릿에 액세스하려면 SQL 함수를 사용해야 합니다. 자세한 내용은 시크릿 관리 및 Streamlit 앱 구성하기 섹션을 참조하십시오.

Git 리포지토리에서 Streamlit 앱 만들기

To create a Streamlit app from a Git repository, run the CREATE STREAMLIT command as shown in the following example:

CREATE STREAMLIT hello_streamlit
  FROM @streamlit_db.streamlit_schema.streamlit_repo/branches/streamlit_branch/
  MAIN_FILE = 'streamlit_main.py'
  QUERY_WAREHOUSE = my_warehouse;
Copy