Skip to content

Développement local

Installez et lancez Potato en local pour le développement et les tests. Couvre l'installation via pip, la configuration, le démarrage du serveur de développement et le diagnostic des problèmes de démarrage courants.

Faites tourner Potato sur votre machine pour développer et tester.

Prérequis

  • Python 3.7 ou version supérieure
  • Le gestionnaire de paquets pip
  • Git (facultatif, pour cloner les exemples)

Installation

Avec pip (recommandé)

bash
pip install potato-annotation

Depuis les sources

bash
git clone https://github.com/davidjurgens/potato.git
cd potato
pip install -e .

Avec les dépendances facultatives

bash
# For audio annotation support
pip install potato-annotation[audio]
 
# For all optional features
pip install potato-annotation[all]

Démarrage rapide

1. Créer un fichier de configuration

Créez 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. Préparer des données d'exemple

Créez 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. Démarrer le serveur

bash
potato start config.yaml

4. Ouvrir l'interface

Rendez-vous sur http://localhost:8000 dans votre navigateur.

Mode développement

Rechargement à chaud

Redémarrage automatique quand la configuration change :

bash
potato start config.yaml --reload

Mode debug

Journalisation détaillée :

bash
potato start config.yaml --debug

Sortie verbeuse

Voir toute l'activité du serveur :

bash
potato start config.yaml --verbose

Arborescence

Organisation de projet recommandée :

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

Tester votre configuration

Valider la configuration

Repérer les erreurs de syntaxe :

bash
potato validate config.yaml

Mode aperçu

Démarrer sans enregistrer les annotations :

bash
potato start config.yaml --preview

Tester avec des données d'exemple

Générer des données de test :

bash
potato generate-data --count 10 --output test_data.json

Problèmes courants

Port déjà utilisé

bash
# Use a different port
potato start config.yaml --port 8080
 
# Or in config.yaml
server:
  port: 8080

Fichier de données introuvable

Les chemins doivent être relatifs à l'emplacement du fichier de configuration :

yaml
# If data is in subdirectory
data_files:
  - path: data/main.json
 
# Or use absolute path
data_files:
  - path: /full/path/to/data.json

Permission refusée

Vérifiez les permissions des fichiers :

bash
chmod 755 annotations/
chmod 644 data/*.json

Plusieurs utilisateurs en local

Pour tester des scénarios multi-utilisateurs :

yaml
allow_all_users: true
url_user_id_param: user_id

Connectez-vous avec différents utilisateurs :

  • http://localhost:8000/?user_id=annotator1
  • http://localhost:8000/?user_id=annotator2

Réinitialiser les annotations

Effacer toutes les annotations et repartir de zéro :

bash
# Remove annotation files
rm -rf annotations/*
 
# Restart server
potato start config.yaml

Variables d'environnement

Configuration par l'environnement :

bash
export POTATO_PORT=8000
export POTATO_DEBUG=true
export POTATO_DATA_PATH=/path/to/data
 
potato start config.yaml

Utilisation avec des environnements virtuels

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

Intégration avec l'IDE

VS Code

Installez l'extension YAML pour la prise en charge du fichier de configuration :

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

PyCharm

Créez une configuration d'exécution :

  1. Add → Python
  2. Script : potato
  3. Paramètres : start config.yaml
  4. Répertoire de travail : le chemin de votre projet

Étapes suivantes