Skip to content

ローカル開発

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.yaml

4. インターフェースへのアクセス

ブラウザで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=annotator1
  • http://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-annotation

Conda

bash
conda create -n potato python=3.10
conda activate potato
pip install potato-annotation

IDE統合

VS Code

設定ファイルサポートのためにYAML拡張機能をインストールする:

json
// settings.json
{
  "yaml.schemas": {
    "https://potato-annotation.com/schema.json": "config.yaml"
  }
}

PyCharm

実行構成をセットアップする:

  1. 追加 → Python
  2. スクリプト:potato
  3. パラメータ:start config.yaml
  4. 作業ディレクトリ:プロジェクトのパス

次のステップ