로컬 개발
개발 및 테스트를 위해 Potato를 로컬에서 설치하고 실행합니다. pip 설치, 구성 설정, 개발 서버 시작, 일반적인 시작 문제 디버깅을 다룹니다.
개발 및 테스트를 위해 로컬 컴퓨터에서 Potato를 실행해 봅니다.
사전 요구 사항
- Python 3.7 이상
- pip 패키지 관리자
- Git (선택 사항, 예제를 복제하는 경우)
설치
pip 사용 (권장)
bash
pip install potato-annotation소스에서 설치
bash
git clone https://github.com/davidjurgens/potato.git
cd potato
pip install -e .선택적 의존성과 함께 설치
bash
# For audio annotation support
pip install potato-annotation[audio]
# For all optional features
pip install potato-annotation[all]빠른 시작
1. 구성 파일 생성
config.yaml을 생성합니다.
yaml
task_name: "My First Annotation Task"
server:
port: 8000
data_files:
- path: data.json
text_field: text
annotation_schemes:
- annotation_type: radio
name: sentiment
description: "What is the sentiment?"
labels:
- Positive
- Negative
- Neutral
output:
path: annotations/2. 샘플 데이터 준비
data.json을 생성합니다.
json
[
{"id": "1", "text": "I love this product!"},
{"id": "2", "text": "This is terrible."},
{"id": "3", "text": "It's okay, nothing special."}
]3. 서버 시작
bash
potato start config.yaml4. 인터페이스 접속
브라우저에서 http://localhost:8000을 엽니다.
개발 모드
핫 리로딩
구성이 변경될 때 자동 재시작을 활성화합니다.
bash
potato start config.yaml --reload디버그 모드
상세 로깅을 활성화합니다.
bash
potato start config.yaml --debug자세한 출력
모든 서버 활동을 확인합니다.
bash
potato start config.yaml --verbose디렉터리 구조
권장 프로젝트 레이아웃:
text
my-annotation-project/
├── config.yaml # Main configuration
├── data/
│ ├── train.json # Training data
│ └── main.json # Annotation data
├── annotations/ # Output directory
├── templates/ # Custom HTML templates
└── static/ # Custom CSS/JS
구성 테스트하기
구성 검증
구문 오류를 확인합니다.
bash
potato validate config.yaml미리보기 모드
주석을 저장하지 않고 시작합니다.
bash
potato start config.yaml --preview샘플 데이터로 테스트
테스트 데이터를 생성합니다.
bash
potato generate-data --count 10 --output test_data.json일반적인 문제
포트가 이미 사용 중
bash
# Use a different port
potato start config.yaml --port 8080
# Or in config.yaml
server:
port: 8080데이터 파일을 찾을 수 없음
경로가 구성 파일 위치를 기준으로 상대 경로인지 확인하십시오.
yaml
# If data is in subdirectory
data_files:
- path: data/main.json
# Or use absolute path
data_files:
- path: /full/path/to/data.json권한 거부됨
파일 권한을 확인합니다.
bash
chmod 755 annotations/
chmod 644 data/*.json로컬에서 여러 사용자
다중 사용자 시나리오를 테스트하려면 다음과 같이 합니다.
yaml
allow_all_users: true
url_user_id_param: user_id다른 사용자로 접속합니다.
http://localhost:8000/?user_id=annotator1http://localhost:8000/?user_id=annotator2
주석 초기화
모든 주석을 지우고 처음부터 다시 시작합니다.
bash
# Remove annotation files
rm -rf annotations/*
# Restart server
potato start config.yaml환경 변수
환경을 통해 구성합니다.
bash
export POTATO_PORT=8000
export POTATO_DEBUG=true
export POTATO_DATA_PATH=/path/to/data
potato start config.yaml가상 환경과 함께 사용하기
venv
bash
python -m venv potato-env
source potato-env/bin/activate # Linux/Mac
potato-env\Scripts\activate # Windows
pip install potato-annotationConda
bash
conda create -n potato python=3.10
conda activate potato
pip install potato-annotationIDE 통합
VS Code
구성 파일 지원을 위해 YAML 확장을 설치합니다.
json
// settings.json
{
"yaml.schemas": {
"https://potato-annotation.com/schema.json": "config.yaml"
}
}PyCharm
실행 구성을 설정합니다.
- Add → Python
- 스크립트:
potato - 매개변수:
start config.yaml - 작업 디렉터리: 프로젝트 경로