التطوير المحلي
إعداد 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-annotationتكامل بيئة التطوير
VS Code
قم بتثبيت إضافة YAML لدعم ملفات الإعداد:
json
// settings.json
{
"yaml.schemas": {
"https://potato-annotation.com/schema.json": "config.yaml"
}
}PyCharm
إعداد تهيئة التشغيل:
- Add → Python
- Script:
potato - Parameters:
start config.yaml - Working directory: مسار مشروعك
الخطوات التالية
- أساسيات الإعداد - تعلم جميع خيارات الإعداد
- تنسيقات البيانات - فهم بنية البيانات
- إعداد الإنتاج - النشر للاستخدام الفعلي