Development Guide - MakerCorn/nbedr GitHub Wiki
Development Guide
Table of Contents
- Development Guide
- or
- Install pyenv if not already installed
- Install Python 3.11
- Ubuntu/Debian
- macOS with Homebrew
- CentOS/RHEL/Fedora
- Format code
- Check linting
- Type checking
- Run tests
- Run all tests
- Run with coverage
- Run specific test file
- Install documentation dependencies
- Build documentation
- Copy example environment file
- Edit with your settings
This guide covers setting up a development environment for nBedR.
Prerequisites
Python Version
nBedR requires Python 3.11 or higher. Python 3.9 and 3.10 are no longer supported.
Check Your Python Version
python3 --version
# or
python3.11 --version
Install Python 3.11+
Using pyenv (Recommended):
# Install pyenv if not already installed
curl https://pyenv.run | bash
# Install Python 3.11
pyenv install 3.11.0
pyenv global 3.11.0
Using conda:
conda install python=3.11
Using system package manager:
# Ubuntu/Debian
sudo apt update
sudo apt install python3.11 python3.11-venv python3.11-dev
# macOS with Homebrew
brew install [email protected]
# CentOS/RHEL/Fedora
sudo dnf install python3.11 python3.11-venv python3.11-devel
Download from python.org: Visit https://www.python.org/downloads/
Quick Setup
Automated Setup
Use the provided setup script:
./scripts/setup_dev.sh
This script will:
- Check for Python 3.11+
- Create a virtual environment
- Install all dependencies
- Run initial code quality checks
Manual Setup
-
Clone the repository:
git clone https://github.com/your-org/nbedr.git cd nbedr
-
Create virtual environment:
python3.11 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install --upgrade pip pip install -e .[dev,all]
-
Verify installation:
python scripts/check_python.py python nbedr.py --help
Development Workflow
Code Quality
Run these commands before committing:
# Format code
black .
isort .
# Check linting
flake8 .
# Type checking
mypy core/ cli/ --ignore-missing-imports
# Run tests
pytest
Pre-commit Hooks
Install pre-commit hooks to automatically run checks:
pip install pre-commit
pre-commit install
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=core --cov=cli --cov-report=html
# Run specific test file
pytest tests/unit/test_embedding_utils.py
Building Documentation
# Install documentation dependencies
pip install -e .[docs]
# Build documentation
cd docs
make html
Project Structure
nbedr/
├── cli/ # Command-line interface
├── core/ # Core application logic
│ ├── clients/ # Embedding provider clients
│ ├── services/ # Business logic services
│ ├── sources/ # Document source handlers
│ ├── utils/ # Utility functions
│ └── vector_stores/ # Vector database implementations
├── deployment/ # Deployment configurations
├── docs/ # Documentation
├── scripts/ # Development scripts
├── tests/ # Test suite
├── templates/ # Prompt templates
├── nbedr.py # Main entry point
└── pyproject.toml # Project configuration
Environment Variables
Create a .env
file for development:
# Copy example environment file
cp deployment/docker/.env.example .env
# Edit with your settings
vim .env
Key environment variables:
EMBEDDING_PROVIDER
: openai, azure_openai, aws_bedrock, etc.OPENAI_API_KEY
: Your OpenAI API keyVECTOR_DATABASE_TYPE
: faiss, pinecone, chromadb, etc.
Troubleshooting
Python Version Issues
If you get Python version errors:
- Check your Python version:
python3 --version
- Install Python 3.11+ using one of the methods above
- Recreate your virtual environment with the correct Python version
Import Errors
If you get import errors:
- Ensure you're in the virtual environment:
source venv/bin/activate
- Install in development mode:
pip install -e .
- Check your PYTHONPATH includes the project directory
Dependency Issues
If you have dependency conflicts:
- Delete the virtual environment:
rm -rf venv
- Recreate it:
python3.11 -m venv venv
- Reinstall dependencies:
pip install -e .[dev,all]
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests and quality checks
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
IDE Configuration
VS Code
Recommended extensions:
- Python
- Pylance
- Black Formatter
- isort
- Flake8
Settings (.vscode/settings.json
):
{
"python.defaultInterpreterPath": "./venv/bin/python",
"python.formatting.provider": "black",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"editor.formatOnSave": true
}
PyCharm
- Set Python interpreter to
./venv/bin/python
- Enable Black formatter in Settings > Tools > External Tools
- Configure Flake8 in Settings > Tools > External Tools
- Enable mypy in Settings > Tools > External Tools
📚 Navigation: Home | Development | Deployment | Security
🔗 Links: Repository | Issues | Releases
Last updated: 2025-06-21 17:09 UTC