From 266628c31bf3c1e94ffb49258d79ffa044b1641f Mon Sep 17 00:00:00 2001 From: "qwen.ai[bot]" Date: Mon, 4 May 2026 19:28:26 +0000 Subject: [PATCH] Setup development environment for local testing with comprehensive dependency management - Added SETUP_DEV.md with complete development setup guide including installation options, testing commands, and troubleshooting - Created requirements-dev.txt with categorized dependencies for core, testing, development tools, ML, dashboard, and API clients - Updated .gitignore with enhanced ignore patterns for development environments and testing artifacts The changes provide a complete localhost development setup that allows easy installation of all required libraries for testing and further development. --- .gitignore | 51 +++++----- SETUP_DEV.md | 216 +++++++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 52 +++++++++++ 3 files changed, 290 insertions(+), 29 deletions(-) create mode 100644 SETUP_DEV.md create mode 100644 requirements-dev.txt diff --git a/.gitignore b/.gitignore index 7034337..5e66593 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,41 @@ ``` -# Python +# Dependencies +venv/ +.venv/ __pycache__/ *.pyc *.pyo *.pyd -.Python -env/ -venv/ -.venv/ -.ENV -.ENV.local +*.egg-info/ +dist/ +build/ +*.so +*.dylib +*.dll + +# Environment .env .env.local -.env.* -.venv/ -venv/ -env/ +*.env.* -# Build/dist -build/ -dist/ -*.egg -*.egg-info/ -*.so -*.whl +# Editors +.vscode/ +.idea/ +*.swp +*.swo +*.tmp -# Testing +# Logs +*.log + +# Tests and coverage .coverage coverage/ htmlcov/ .pytest_cache/ .mypy_cache/ -# Logs -*.log - # OS .DS_Store Thumbs.db - -# Editors -.vscode/ -.idea/ -*.swp -*.swo -*.tmp ``` \ No newline at end of file diff --git a/SETUP_DEV.md b/SETUP_DEV.md new file mode 100644 index 0000000..d24112e --- /dev/null +++ b/SETUP_DEV.md @@ -0,0 +1,216 @@ +# 🚀 Setup Development Environment - Wunaraha + +Panduan lengkap untuk menyiapkan environment development dan testing di localhost. + +## 📋 Prerequisites + +- Python 3.8 atau lebih tinggi +- pip (Python package manager) +- git + +## 🔧 Langkah Instalasi + +### Opsi 1: Menggunakan requirements-dev.txt (RECOMMENDED) + +Instal semua dependensi yang diperlukan untuk development dan testing: + +```bash +# Install semua dependencies +pip install -r requirements-dev.txt +``` + +### Opsi 2: Menggunakan pyproject.toml + +Instal package dalam mode development dengan semua dependencies: + +```bash +# Install package dalam mode editable dengan semua dependencies +pip install -e ".[all]" +``` + +Atau instal dengan kategori spesifik: + +```bash +# Hanya dependencies development +pip install -e ".[dev]" + +# Development + Machine Learning +pip install -e ".[dev,ml]" + +# Development + Dashboard +pip install -e ".[dev,dashboard]" + +# Development + API clients +pip install -e ".[dev,api]" +``` + +### Opsi 3: Menggunakan requirements.txt (Minimal) + +Untuk instalasi minimal tanpa optional dependencies: + +```bash +pip install -r requirements.txt +``` + +## 🎯 Quick Start Testing + +Setelah instalasi selesai, jalankan tests: + +```bash +# Jalankan semua tests +pytest + +# Jalankan tests dengan coverage report +pytest --cov=wunaraha --cov-report=html + +# Jalankan tests dengan verbose output +pytest -v + +# Jalankan test spesifik +pytest tests/test_auditor.py +``` + +## 🛠️ Development Tools + +Setelah instalasi, Anda dapat menggunakan tools berikut: + +### Code Formatting +```bash +# Format code dengan Black +black wunaraha/ tests/ + +# Sort imports dengan isort +isort wunaraha/ tests/ +``` + +### Code Linting +```bash +# Check code style dengan flake8 +flake8 wunaraha/ tests/ + +# Type checking dengan mypy +mypy wunaraha/ +``` + +### Pre-commit Hooks +```bash +# Install pre-commit hooks +pre-commit install + +# Run pre-commit manually +pre-commit run --all-files +``` + +## 📦 Struktur Dependencies + +### Core Dependencies (Wajib) +- `transformers` - Model AI untuk validasi +- `torch` - Deep learning framework +- `pandas` - Data processing +- `numpy` - Numerical computing +- `requests` - HTTP client + +### Testing Dependencies +- `pytest` - Testing framework +- `pytest-cov` - Coverage reporting +- `pytest-asyncio` - Async test support + +### Development Tools +- `black` - Code formatter +- `flake8` - Code linter +- `mypy` - Type checker +- `isort` - Import sorter +- `pre-commit` - Git hooks manager + +### Optional Dependencies + +#### Machine Learning +- `scikit-learn` - ML utilities +- `sentence-transformers` - Sentence embeddings + +#### Dashboard & Visualization +- `streamlit` - Web dashboard +- `plotly` - Interactive plots + +#### API Clients +- `tweepy` - Twitter API +- `Mastodon.py` - Mastodon API +- `python-dotenv` - Environment variables + +#### Utilities +- `ipython` - Interactive Python shell +- `jupyter` - Jupyter notebooks + +## 🔍 Verifikasi Instalasi + +Setelah instalasi, verifikasi bahwa semua package terinstall: + +```bash +# Cek versi Python +python --version + +# List semua installed packages +pip list + +# Cek package spesifik +pip show pytest +pip show transformers +``` + +## 🐛 Troubleshooting + +### Issue: torch installation gagal +```bash +# Install torch dari PyTorch index +pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cpu +``` + +### Issue: dependencies conflict +```bash +# Upgrade pip terlebih dahulu +pip install --upgrade pip + +# Clear cache dan reinstall +pip cache purge +pip install -r requirements-dev.txt --no-cache-dir +``` + +### Issue: permission error +```bash +# Gunakan user install +pip install -r requirements-dev.txt --user + +# Atau gunakan virtual environment (recommended) +python -m venv venv +source venv/bin/activate # Linux/Mac +# atau +venv\Scripts\activate # Windows +pip install -r requirements-dev.txt +``` + +## 💡 Best Practices + +1. **Gunakan Virtual Environment** - Selalu gunakan venv atau conda untuk mengisolasi dependencies +2. **Pin Versions** - Untuk production, pertimbangkan untuk pin versi spesifik +3. **Regular Updates** - Update dependencies secara berkala untuk security patches +4. **Test Before Commit** - Selalu jalankan tests sebelum commit perubahan + +## 📝 Contoh Penggunaan + +```python +# Import library setelah instalasi +from wunaraha import Auditor + +# Initialize auditor +auditor = Auditor() + +# Run validation +result = auditor.validate("your-text-here") +print(result) +``` + +## 🆘 Butuh Bantuan? + +- Dokumentasi: Lihat README.md +- Issues: https://github.com/wunaraha/wunaraha/issues +- Contributing: Lihat CONTRIBUTING.md diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..6291fa5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,52 @@ +# Requirements untuk Wunaraha - Altmetric Validator AI +# Lengkap untuk development dan testing di localhost + +# =========================================== +# CORE DEPENDENCIES +# =========================================== +transformers>=4.30.0 +torch>=2.0.0 +pandas>=1.5.0 +numpy>=1.24.0 +requests>=2.28.0 + +# =========================================== +# TESTING +# =========================================== +pytest>=7.0.0 +pytest-cov>=4.0.0 +pytest-asyncio>=0.21.0 + +# =========================================== +# DEVELOPMENT TOOLS +# =========================================== +black>=23.0.0 +flake8>=6.0.0 +mypy>=1.0.0 +isort>=5.12.0 +pre-commit>=3.0.0 + +# =========================================== +# MACHINE LEARNING (OPTIONAL) +# =========================================== +scikit-learn>=1.2.0 +sentence-transformers>=2.2.0 + +# =========================================== +# DASHBOARD & VISUALIZATION (OPTIONAL) +# =========================================== +streamlit>=1.20.0 +plotly>=5.14.0 + +# =========================================== +# API CLIENTS (OPTIONAL) +# =========================================== +tweepy>=4.14.0 +Mastodon.py>=1.5.0 +python-dotenv>=1.0.0 + +# =========================================== +# UTILITIES +# =========================================== +ipython>=8.0.0 +jupyter>=1.0.0