Streamlit 앱 만들기

전제 조건

Snowflake CLI 를 사용하여 Streamlit 앱을 생성하기 전에 다음 전제 조건을 충족해야 합니다.

  • Streamlit 앱 생성 및 사용에 필요한 권한 에 설명된 대로 자신의 계정에 올바른 권한이 있는지 확인하십시오.

  • Streamlit 앱 파일을 업로드할 수 있는 명명된 스테이지를 생성하거나 이 스테이지에 액세스할 수 있는지 확인하십시오.

Streamlit 앱 부트스트랩

snow init 명령은 Streamlit 앱 만들기를 시작하는 데 유용한 샘플 파일 세트가 있는 로컬 디렉터리를 만듭니다. 이 명령을 실행하면 Snowflake CLI 는 다음과 같은 디렉터리 구조를 생성합니다.

example_streamlit/            - project name (default: example_streamlit)
  snowflake.yml               - configuration for snow streamlit commands
  environment.yml             - additional config for Streamlit, for example installing packages
  streamlit_app.py            - entrypoint file of the app
  pages/                      - directory name for Streamlit pages (default pages)
  common/                     - example “shared library”

Streamlit 앱을 초기화하려면 다음 명령을 입력합니다.

snow init new_streamlit_project --template example_streamlit -D query_warehouse=dev_warehouse -D stage=testing
Copy

조심

프로젝트 디렉터리 내의 파일은 Snowflake CLI 에 의해 처리되며 다른 snow streamlit 명령을 실행할 때 Snowflake에 업로드될 수 있습니다. 프로젝트 디렉터리의 파일에 민감한 정보를 포함하는 경우에는 주의해야 합니다.

파일 구조에 대한 자세한 내용은 로컬 파일 시스템에 Streamlit 파일 만들기 섹션을 참조하십시오.

Streamlit 앱에 대한 프로젝트 정의를 만듭니다.

Snowflake의 각 Streamlit 앱에는 반드시 snowflake.yml 프로젝트 정의 파일이 포함되어야 합니다. Streamlit은 프로젝트 정의 파일당 1개의 애플리케이션으로 제한됩니다.

snowflake.yml 프로젝트 정의 파일 샘플은 다음과 같습니다.

definition_version: 2
entities:
  my_streamlit:
    type: streamlit
    identifier: streamlit_app
    stage: my_streamlit_stage
    query_warehouse: my_streamlit_warehouse
    main_file: streamlit_app.py
    pages_dir: pages/
    external_access_integrations:
      - test_egress
    secrets:
      dummy_secret: "db.schema.dummy_secret"
    imports:
      - "@my_stage/foo.py"
    artifacts:
      - common/hello.py
      - environment.yml
Copy

다음 테이블은 Streamlit 프로젝트 정의의 속성을 설명합니다.

Streamlit 프로젝트 정의 속성

속성

정의

식별자

선택 사항, 문자열

엔터티에 대한 선택적 Snowflake 식별자입니다. 값은 다음 형식일 수 있습니다.

  • 문자열 식별자 텍스트

    identifer: my-streamlit-id
    
    Copy

    따옴표로 묶지 않은 식별자와 따옴표로 묶은 식별자가 모두 지원됩니다. 따옴표로 묶인 식별자를 사용하려면 YAML 값에 따옴표(예: ’”My Streamlit Application”’)를 포함합니다.

  • 오브젝트

    identifer:
      name: my-streamlit-id
      schema: my-schema # optional
      database: my-db # optional
    
    Copy

    참고

    schema 또는 database 를 지정하고 name 속성에 정규화된 이름(예: mydb.schema1.my-app)을 사용하면 오류가 발생합니다.

유형

선택 사항, 문자열

streamlit 이어야 합니다.

comment

선택 사항, 문자열

Streamlit 대시보드에 대한 설명.

제목

선택 사항, 문자열

Streamlit 대시보드의 사람이 읽을 수 있는 제목입니다.

스테이지

선택 사항, 문자열

앱의 아티팩트가 저장되는 스테이지입니다. 기본값: 없음.

query_warehouse

필수, 문자열

앱을 호스팅하는 Snowflake 웨어하우스입니다.

main_file

선택 사항, 문자열

Streamlit 앱의 진입점 파일 입니다. 기본값: “streamlit_app.py”.

pages_dir

선택 사항, 문자열

Streamlit 페이지 입니다. 기본값: “pages”.

아티팩트

필수, 문자열 시퀀스

배포 아티팩트에 포함되어야 하는 파일 목록입니다.