Development Setup
Complete guide to setting up your development environment for redis-memory.
Prerequisites
Before you begin, ensure you have:
- Docker: Required for all development workflows
- Git: For version control
- VS Code: Optional but highly recommended
Installing Docker
macOS:
Windows: Download from Docker Desktop for Windows
Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install docker.io docker-compose
sudo usermod -aG docker $USER
# Log out and back in
Setup Options
Option 1: VS Code Dev Containers (Recommended)
This is the easiest and most consistent setup.
Step 1: Install VS Code Extensions
Install the "Dev Containers" extension:
1. Open VS Code
2. Press Cmd/Ctrl + Shift + X
3. Search for "Dev Containers"
4. Install the extension by Microsoft
Step 2: Open in Container
- Open the redis-memory project in VS Code
- Press
Cmd/Ctrl + Shift + P - Select "Dev Containers: Reopen in Container"
- Wait for the container to build (first time takes a few minutes)
Step 3: You're Done!
The devcontainer includes: - Python 3.11 - Redis server (automatically started) - All dependencies pre-installed - Pre-configured VS Code settings
Option 2: Docker Compose
Use Docker without VS Code.
Run Tests:
Reformat Code:
Validate Docs:
Option 3: Virtual Environment
For those who prefer local Python environments.
Step 1: Create Virtual Environment
Step 2: Activate
Step 3: Install Dependencies
pip install --upgrade pip
pip install -e .
pip install -e .[test]
pip install -e .[dev]
pip install -e .[docs]
Step 4: Start Redis
You'll need Redis running locally:
# macOS
brew install redis
brew services start redis
# Ubuntu/Debian
sudo apt-get install redis-server
sudo systemctl start redis-server
# Docker
docker run -d -p 6379:6379 redis:latest
Verifying Your Setup
Test the Installation
from redis_memory import Memory
mem = Memory()
mem.test = "Hello, World!"
print(mem.test) # Should print: Hello, World!
Run the Test Suite
In Dev Container or with Virtual Environment:
Using Docker:
Check Code Formatting
VS Code Tasks
The project includes pre-configured VS Code tasks:
Access tasks: Cmd/Ctrl + Shift + P → "Tasks: Run Task"
Available tasks: - Run Unit Tests (Run inside the .devcontainer): Run tests with pytest - Run Unit Tests in Docker: Run tests in isolated Docker environment - Reformat Code: Auto-format code with black, docformatter, and isort - Reformat and Lint: Format and run linter - validate-docs: Validate documentation
Environment Variables
Create a .env file for local development:
Load it in your code:
Project Structure
redis-memory/
├── .devcontainer/ # Dev container configuration
├── .github/
│ └── workflows/
│ └── ci.yaml # CI/CD pipeline
├── .vscode/
│ └── tasks.json # VS Code tasks
├── docs/ # Documentation source
├── docs-validate/ # Docs validation Docker setup
├── reformat/ # Code formatting Docker setup
├── scripts/ # Utility scripts
├── src/
│ └── redis_memory/
│ └── __init__.py # Main source code
├── tests/
│ ├── test_memory.py # Test suite
│ └── docker-compose.yaml # Test environment
├── mkdocs.yml # Documentation config
└── pyproject.toml # Project metadata
Common Issues
Redis Connection Error
Problem: redis.exceptions.ConnectionError: Error connecting to Redis
Solution:
- Ensure Redis is running: redis-cli ping should return PONG
- Check REDIS_HOST environment variable
- Verify Redis port (default: 6379)
Import Errors
Problem: ModuleNotFoundError: No module named 'redis_memory'
Solution:
Docker Permission Errors
Problem: Permission denied on Docker commands
Solution:
Port Already in Use
Problem: Port 6379 already in use
Solution:
# Find and kill the process
lsof -i :6379
kill -9 <PID>
# Or use a different port
export REDIS_PORT=6380
Next Steps
Once your environment is set up:
- Read the Contributing Guide
- Look for good first issues
- Join discussions on GitHub
- Start coding! 🚀