;
};
// Use useCallback for stable references
const Parent = () => {
const handleAction = useCallback((id: string) => {
// Handle action
}, []);
return ;
};
```
### Debugging
#### Python Debugging
```python
import logging
import pdb
# Set up detailed logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
def debug_function():
logger.debug("Debug information")
# Set breakpoint for debugging
pdb.set_trace()
# Process continues...
```
#### Frontend Debugging
```typescript
// Use React Developer Tools
// Add debugging props in development
const DebugComponent = ({ data }: Props) => {
useEffect(() => {
if (process.env.NODE_ENV === "development") {
console.log("Component data:", data);
}
}, [data]);
return
{/* Component content */}
;
};
```
### Docker Development
#### Development Dockerfile
```dockerfile
FROM frigate:dev as dev
# Install development dependencies
RUN pip install debugpy pytest-cov
# Enable development features
ENV PYTHONPATH=/workspace/frigate
ENV FRIGATE_CONFIG_FILE=/config/config.yml
# Expose debug port
EXPOSE 5678
CMD ["python", "-m", "debugpy", "--listen", "0.0.0.0:5678", "--wait-for-client", "-m", "frigate"]
```
#### Docker Compose for Development
```yaml
version: "3.8"
services:
frigate:
build:
context: .
dockerfile: docker/main/Dockerfile
target: devcontainer
volumes:
- .:/workspace/frigate
- ./config:/config
ports:
- "5000:5000" # Web interface
- "5678:5678" # Debug port
environment:
- PYTHONPATH=/workspace/frigate
```
### Integration Testing
#### Test Configuration
```yaml
# test_config.yml
cameras:
test_camera:
ffmpeg:
inputs:
- path: /dev/video0
roles: [detect]
detect:
enabled: true
detectors:
cpu:
type: cpu
```
#### End-to-End Testing
```python
import pytest
from frigate.app import FrigateApp
from frigate.config import FrigateConfig
@pytest.fixture
def test_app():
config = FrigateConfig.load_file("test_config.yml")
app = FrigateApp(config)
yield app
app.stop()
def test_detection_pipeline(test_app):
# Test full detection pipeline
pass
```
### Contributing Guidelines
1. **Fork and Clone**: Fork the repository and clone locally
2. **Branch**: Create feature branches from master
3. **Develop**: Follow coding standards and patterns
4. **Test**: Write and run tests for new features
5. **Document**: Update documentation as needed
6. **Pull Request**: Submit PR with clear description
7. **Review**: Address review feedback promptly
### Common Development Tasks
#### Adding a New Detector
1. Create detector plugin in `frigate/detectors/plugins/`
2. Add configuration model in `frigate/detectors/detector_config.py`
3. Update detector factory in `frigate/detectors/__init__.py`
4. Add tests and documentation
#### Adding a New API Endpoint
1. Define request/response models with Pydantic
2. Create endpoint in appropriate router module
3. Add authentication/authorization if needed
4. Write tests for the endpoint
5. Update API documentation
#### Adding a New React Component
1. Create component in appropriate directory
2. Define TypeScript interfaces for props
3. Implement with proper error handling
4. Add to component exports
5. Write tests and stories (if using Storybook)
This development guide provides the foundation for contributing to Frigate while maintaining code quality and architectural consistency.