| # π οΈ Scripts Usage Guide |
|
|
| This folder contains useful development, testing, and deployment scripts for the Enhanced Fake News Detection System. |
|
|
| ## π **Available Scripts** |
|
|
| ### π **Verification & Testing** |
|
|
| #### `verify_project.py` |
| **Purpose**: Comprehensive project verification before deployment |
| ```bash |
| python scripts/verify_project.py |
| ``` |
| **What it checks**: |
| - β
Project structure completeness |
| - β
Python syntax validation |
| - β
Documentation completeness |
| - β
Docker configuration |
| - β
Git repository status |
| |
| #### `final_verification.py` |
| **Purpose**: Final deployment readiness check with Docker testing |
| ```bash |
| python scripts/final_verification.py |
| ``` |
| **What it checks**: |
| - β
All project verification checks |
| - β
Docker build testing |
| - β
Docker Compose validation |
| - β
System requirements |
| - β
Deployment summary |
| |
| #### `health_check.py` |
| **Purpose**: Application health monitoring and status checks |
| ```bash |
| python scripts/health_check.py |
| # Or with custom URL |
| python scripts/health_check.py --url http://localhost:8080 |
| ``` |
| **What it monitors**: |
| - β
API endpoint health |
| - β
Database connectivity |
| - β
Service response times |
| - β
System resource usage |
|
|
| #### `performance_benchmark.py` |
| **Purpose**: Performance testing and benchmarking |
| ```bash |
| python scripts/performance_benchmark.py |
| ``` |
| **What it tests**: |
| - β
API response times |
| - β
Throughput testing |
| - β
Memory usage analysis |
| - β
Concurrent request handling |
| |
| #### `validate_environment.py` |
| **Purpose**: Environment setup validation |
| ```bash |
| python scripts/validate_environment.py |
| ``` |
| **What it validates**: |
| - β
Python dependencies |
| - β
Environment variables |
| - β
System requirements |
| - β
Configuration files |
| |
| --- |
| |
| ### π³ **Docker Management** |
| |
| #### `docker-dev.sh` |
| **Purpose**: Docker development environment management |
| ```bash |
| # Make executable (Linux/Mac) |
| chmod +x scripts/docker-dev.sh |
| |
| # Start development environment |
| ./scripts/docker-dev.sh start |
| |
| # Stop development environment |
| ./scripts/docker-dev.sh stop |
| |
| # Rebuild and restart |
| ./scripts/docker-dev.sh restart |
| |
| # View logs |
| ./scripts/docker-dev.sh logs |
| |
| # Clean up |
| ./scripts/docker-dev.sh clean |
| ``` |
| |
| #### `docker-prod.sh` |
| **Purpose**: Docker production environment management |
| ```bash |
| # Make executable (Linux/Mac) |
| chmod +x scripts/docker-prod.sh |
| |
| # Deploy to production |
| ./scripts/docker-prod.sh deploy |
| |
| # Stop production |
| ./scripts/docker-prod.sh stop |
| |
| # Update production |
| ./scripts/docker-prod.sh update |
| |
| # View production logs |
| ./scripts/docker-prod.sh logs |
| ``` |
| |
| --- |
| |
| ### π **Local Development** |
| |
| #### `run_local.sh` (Linux/Mac) |
| **Purpose**: Local development environment setup |
| ```bash |
| # Make executable |
| chmod +x scripts/run_local.sh |
| |
| # Start local development |
| ./scripts/run_local.sh |
| |
| # Start with specific mode |
| ./scripts/run_local.sh --mode development |
| |
| # Skip dependency installation |
| ./scripts/run_local.sh --skip-deps |
| |
| # Run in background |
| ./scripts/run_local.sh --detached |
| ``` |
|
|
| #### `run_local.ps1` (Windows) |
| **Purpose**: Windows local development setup |
| ```powershell |
| # Run in PowerShell |
| .\scripts\run_local.ps1 |
|
|
| # With parameters |
| .\scripts\run_local.ps1 -Mode development -SkipDeps |
| ``` |
| |
| #### `run_tests.sh` |
| **Purpose**: Test execution and validation |
| ```bash |
| # Make executable |
| chmod +x scripts/run_tests.sh |
| |
| # Run all tests |
| ./scripts/run_tests.sh |
| |
| # Run specific test suite |
| ./scripts/run_tests.sh --suite unit |
| ./scripts/run_tests.sh --suite integration |
| ./scripts/run_tests.sh --suite e2e |
| |
| # Run with coverage |
| ./scripts/run_tests.sh --coverage |
| |
| # Run in verbose mode |
| ./scripts/run_tests.sh --verbose |
| ``` |
|
|
| --- |
|
|
| ## π― **Common Workflows** |
|
|
| ### **1. New Developer Setup** |
| ```bash |
| # 1. Verify project setup |
| python scripts/verify_project.py |
| |
| # 2. Validate environment |
| python scripts/validate_environment.py |
| |
| # 3. Start local development |
| ./scripts/run_local.sh |
| |
| # 4. Run tests to ensure everything works |
| ./scripts/run_tests.sh |
| ``` |
|
|
| ### **2. Before Deployment** |
| ```bash |
| # 1. Run comprehensive verification |
| python scripts/final_verification.py |
| |
| # 2. Performance benchmark |
| python scripts/performance_benchmark.py |
| |
| # 3. Deploy with Docker |
| ./scripts/docker-prod.sh deploy |
| ``` |
|
|
| ### **3. Health Monitoring** |
| ```bash |
| # Check application health |
| python scripts/health_check.py |
| |
| # Continuous monitoring (every 30 seconds) |
| watch -n 30 python scripts/health_check.py |
| ``` |
|
|
| ### **4. Development Workflow** |
| ```bash |
| # Start development environment |
| ./scripts/docker-dev.sh start |
| |
| # Make changes to code... |
| |
| # Run tests |
| ./scripts/run_tests.sh |
| |
| # Restart with changes |
| ./scripts/docker-dev.sh restart |
| |
| # Check health |
| python scripts/health_check.py |
| ``` |
|
|
| --- |
|
|
| ## π§ **Script Requirements** |
|
|
| ### **Python Scripts** |
| - Python 3.8+ |
| - Dependencies from `requirements.txt` |
| - Some scripts may need additional packages (specified in script headers) |
|
|
| ### **Shell Scripts** |
| - **Linux/Mac**: Bash shell |
| - **Windows**: PowerShell 5.0+ |
| - Docker and Docker Compose installed |
| - Git (for some verification scripts) |
|
|
| --- |
|
|
| ## π **Script Output Examples** |
|
|
| ### **Verification Success** |
| ``` |
| π Enhanced Fake News Detection System - Project Verification |
| ====================================================================== |
| β
PASS Project Structure |
| β
PASS Python Dependencies |
| β
PASS Documentation |
| β
PASS Docker Availability |
| β
PASS Docker Build |
| β
PASS Docker Compose |
| β
PASS Git Status |
| |
| Score: 7/7 checks passed |
| π ALL CHECKS PASSED! |
| ``` |
|
|
| ### **Health Check Success** |
| ``` |
| π₯ Application Health Check |
| ====================================================================== |
| β
API Health: HEALTHY (200ms) |
| β
Database: CONNECTED |
| β
Memory Usage: 45% (2.1GB/4.0GB) |
| β
CPU Usage: 12% |
| β
Disk Space: 78% available |
| |
| Overall Status: HEALTHY π’ |
| ``` |
|
|
| --- |
|
|
| ## π¨ **Troubleshooting** |
|
|
| ### **Permission Issues (Linux/Mac)** |
| ```bash |
| # Make scripts executable |
| chmod +x scripts/*.sh |
| ``` |
|
|
| ### **PowerShell Execution Policy (Windows)** |
| ```powershell |
| # Allow script execution |
| Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser |
| ``` |
|
|
| ### **Docker Issues** |
| ```bash |
| # Ensure Docker is running |
| docker --version |
| docker-compose --version |
| |
| # Check Docker daemon |
| docker ps |
| ``` |
|
|
| --- |
|
|
| ## π **Adding New Scripts** |
|
|
| When adding new scripts to this folder: |
|
|
| 1. **Follow naming convention**: `action_description.py` or `action_description.sh` |
| 2. **Add documentation**: Include usage instructions in script header |
| 3. **Update this README**: Add the new script to the appropriate section |
| 4. **Make executable**: `chmod +x scripts/new_script.sh` |
| 5. **Test thoroughly**: Ensure script works in different environments |
|
|
| --- |
|
|
| **π οΈ These scripts help streamline development, testing, and deployment workflows for the Enhanced Fake News Detection System.** |