Skip to content

미리 보기 CLI

Potato의 미리 보기 CLI를 사용하여 전체 서버를 시작하지 않고도 YAML 구성을 검증하고, 주석 스키마를 검사하며, 인터페이스의 정적 미리 보기를 렌더링할 수 있습니다.

미리 보기 CLI는 주석 구성을 검증하고 전체 서버를 실행하지 않고도 스키마가 어떻게 렌더링되는지 미리 보여줍니다. 이는 빠른 프로토타이핑, 디버깅, CI/CD 검증에 유용합니다.

개요

미리 보기 CLI는 다음을 제공합니다.

  • 구성 검증: 배포 전에 오류와 경고를 확인합니다
  • 스키마 미리 보기: 주석 스키마가 HTML로 어떻게 렌더링되는지 확인합니다
  • 키 바인딩 충돌 감지: 충돌하는 키보드 단축키를 식별합니다
  • 여러 출력 형식: 요약, HTML, JSON 또는 레이아웃 전용 스니펫

기본 사용법

bash
# Default summary output
python -m potato.preview_cli config.yaml
 
# Or using the module directly
python -m potato.preview_cli path/to/your/config.yaml

출력 형식

요약 (기본값)

구성의 텍스트 요약을 표시합니다.

bash
python -m potato.preview_cli config.yaml

출력:

text
============================================================
ANNOTATION TASK PREVIEW
============================================================
Task Name: Sentiment Annotation
Task Directory: ./my_task

Validation: PASSED

ANNOTATION SCHEMAS (2 total):
----------------------------------------
  [radio] sentiment
          Select the sentiment of the text...
          Labels: 3
          Keybindings: 3

  [multiselect] topics
          Select all relevant topics...
          Labels: 5
          Keybindings: 0

============================================================

HTML 출력

전체 HTML 페이지 미리 보기를 생성합니다.

bash
python -m potato.preview_cli config.yaml --format html > preview.html

브라우저에서 preview.html을 열어 주석 스키마가 어떻게 보일지 확인하십시오.

JSON 출력

프로그래밍 방식 처리를 위한 구조화된 JSON 출력을 생성합니다.

bash
python -m potato.preview_cli config.yaml --format json

레이아웃 전용 HTML

주석 스키마 HTML 스니펫만 생성합니다.

bash
python -m potato.preview_cli config.yaml --layout-only > task_layout.html

이는 사용자 지정 템플릿에 삽입하거나 스키마 렌더링을 독립적으로 테스트하는 데 유용합니다.

명령줄 옵션

옵션약어설명
--format-f출력 형식: summary, html 또는 json
--layout-only-l작업 레이아웃 HTML 스니펫만 출력
--verbose-v상세/디버그 출력 활성화

구성 검증

미리 보기 CLI는 구성을 검증하고 문제를 보고합니다.

오류 (차단)

text
ERROR: Missing required field 'annotation_task_name'
ERROR: Must have either 'data_files' or 'data_directory'

경고 (비차단)

text
WARNING: No annotation schemes found in configuration
WARNING: Key '1' used by both 'schema1:Label1' and 'schema2:Label2'

종료 코드

  • 0: 구성이 유효함
  • 1: 구성에 오류가 있음

CI/CD 파이프라인에서 종료 코드를 사용하십시오.

bash
python -m potato.preview_cli config.yaml || echo "Config validation failed"

사용 사례

빠른 프로토타이핑

스키마 디자인을 빠르게 반복합니다.

bash
# Edit config, then preview immediately
python -m potato.preview_cli config.yaml --format html > preview.html && open preview.html

CI/CD 통합

배포 파이프라인에서 구성을 검증합니다.

yaml
# .github/workflows/validate.yml
- name: Validate Potato Config
  run: python -m potato.preview_cli configs/production.yaml

템플릿 개발

사용자 지정 템플릿 통합을 위한 레이아웃 스니펫을 생성합니다.

bash
python -m potato.preview_cli config.yaml --layout-only > templates/includes/schemas.html

API 레퍼런스

미리 보기 CLI 함수는 프로그래밍 방식으로도 사용할 수 있습니다.

python
from potato.preview_cli import (
    load_config,
    validate_config,
    get_annotation_schemes,
    detect_keybinding_conflicts,
    generate_preview_html,
)
 
# Load and validate
config = load_config("config.yaml")
issues = validate_config(config)
 
# Extract schemes and check for conflicts
schemes = get_annotation_schemes(config)
conflicts = detect_keybinding_conflicts(schemes)
 
# Generate output
html = generate_preview_html(schemes)

문제 해결

"Module not found" 오류

Potato가 설치되어 있는지 확인하십시오.

bash
pip install potato-annotation

스키마 렌더링 오류

스키마 렌더링에 실패하면 출력에 오류 메시지가 포함됩니다. 스키마 구성이 완전한지 확인하십시오.

더 읽어보기

구현 세부 사항은 원본 문서를 참조하십시오.