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

تكامل بيئة التطوير

VS Code

قم بتثبيت إضافة YAML لدعم ملفات الإعداد:

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

PyCharm

إعداد تهيئة التشغيل:

  1. Add → Python
  2. Script: potato
  3. Parameters: start config.yaml
  4. Working directory: مسار مشروعك

الخطوات التالية