ローカル開発
Potatoをローカル開発とテスト用にセットアップする方法。
ローカル開発
ローカルマシンで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
実行構成をセットアップする:
- 追加 → Python
- スクリプト:
potato - パラメータ:
start config.yaml - 作業ディレクトリ:プロジェクトのパス