Skip to content

Commit 7d35c95

Browse files
authored
Merge pull request #1931 from bluewave-labs/develop
Merging Develop into Master: August 18th 2025
2 parents 4d197d2 + e459444 commit 7d35c95

File tree

235 files changed

+22043
-3185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+22043
-3185
lines changed

BiasAndFairnessModule/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<<<<<<< HEAD
2+
*.zip
3+
=======
4+
/artifacts
5+
>>>>>>> upstream/develop
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Installation Guide
2+
3+
This guide covers how to install and set up the Bias and Fairness Module.
4+
5+
## Prerequisites
6+
7+
- Python 3.8 or higher (tested with Python 3.12)
8+
- pip package manager
9+
- Virtual environment (recommended)
10+
11+
## Quick Start
12+
13+
### 1. Clone the Repository
14+
15+
```bash
16+
git clone <repository-url>
17+
cd BiasAndFairnessModule
18+
```
19+
20+
### 2. Create and Activate Virtual Environment
21+
22+
```bash
23+
# Create virtual environment
24+
python -m venv venv
25+
26+
# Activate virtual environment
27+
# On macOS/Linux:
28+
source venv/bin/activate
29+
30+
# On Windows:
31+
venv\Scripts\activate
32+
```
33+
34+
### 3. Install Dependencies
35+
36+
#### Option A: Install with Flexible Versions (Recommended)
37+
38+
```bash
39+
pip install -r requirements.txt
40+
```
41+
42+
#### Option B: Install with Exact Versions (Reproducible)
43+
44+
```bash
45+
pip install -r requirements-exact.txt
46+
```
47+
48+
#### Option C: Install Development Dependencies
49+
50+
```bash
51+
pip install -r requirements-dev.txt
52+
```
53+
54+
## Dependency Categories
55+
56+
### Core Dependencies
57+
58+
- **numpy**: Numerical computing (version 1.26.4, < 2.0.0 for compatibility)
59+
- **pandas**: Data manipulation and analysis
60+
- **pydantic**: Data validation and settings management
61+
- **pyyaml**: YAML configuration file parsing
62+
63+
### Machine Learning and Fairness
64+
65+
- **scikit-learn**: Machine learning algorithms and utilities
66+
- **fairlearn**: Fairness metrics and algorithms
67+
- **langfair**: Language model fairness evaluation
68+
69+
### Deep Learning and Transformers
70+
71+
- **torch**: PyTorch deep learning framework
72+
- **transformers**: Hugging Face transformers library
73+
- **sentence-transformers**: Sentence embedding models
74+
- **huggingface-hub**: Model and dataset hub integration
75+
76+
### Data Handling
77+
78+
- **datasets**: Hugging Face datasets library
79+
- **pyarrow**: Fast data serialization
80+
81+
### Utilities
82+
83+
- **tqdm**: Progress bars for long-running operations
84+
85+
## Version Compatibility Notes
86+
87+
### NumPy Version Constraint
88+
89+
The module requires NumPy version **>= 1.26.4, < 2.0.0** due to:
90+
91+
- Compatibility with `langfair` package
92+
- Stability with existing machine learning ecosystem
93+
- Avoidance of breaking changes in NumPy 2.x
94+
95+
### PyTorch Installation
96+
97+
For GPU support, you may need to install PyTorch with CUDA:
98+
99+
```bash
100+
# For CUDA 11.8
101+
pip install torch>=2.7.0+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
102+
103+
# For CUDA 12.1
104+
pip install torch>=2.7.0+cu121 --extra-index-url https://download.pytorch.org/whl/cu121
105+
```
106+
107+
## Development Setup
108+
109+
### 1. Install Development Dependencies
110+
111+
```bash
112+
pip install -r requirements-dev.txt
113+
```
114+
115+
### 2. Install Pre-commit Hooks (Optional)
116+
117+
```bash
118+
pre-commit install
119+
```
120+
121+
### 3. Verify Installation
122+
123+
```bash
124+
# Run tests
125+
make test
126+
127+
# Run code quality checks
128+
make check
129+
```
130+
131+
## Troubleshooting
132+
133+
### Common Issues
134+
135+
#### NumPy Version Conflicts
136+
137+
If you encounter NumPy version conflicts:
138+
139+
```bash
140+
pip uninstall numpy
141+
pip install "numpy>=1.26.4,<2.0.0"
142+
```
143+
144+
#### Import Errors
145+
146+
If you get import errors:
147+
148+
1. Ensure you're in the virtual environment
149+
2. Check that all dependencies are installed
150+
3. Verify Python path includes the project directory
151+
152+
#### CUDA Issues
153+
154+
If PyTorch CUDA is not working:
155+
156+
1. Check CUDA version: `nvidia-smi`
157+
2. Install matching PyTorch version
158+
3. Verify GPU drivers are up to date
159+
160+
### Environment Variables
161+
162+
Set these environment variables if needed:
163+
164+
```bash
165+
export PYTHONPATH="${PYTHONPATH}:/path/to/BiasAndFairnessModule/src"
166+
export CUDA_VISIBLE_DEVICES=0 # For GPU usage
167+
```
168+
169+
## Verification
170+
171+
After installation, verify everything works:
172+
173+
```bash
174+
# Run the test suite
175+
python run_tests.py
176+
177+
# Test basic functionality
178+
python -c "from src import ConfigManager; print('✅ Installation successful!')"
179+
```
180+
181+
## Updating Dependencies
182+
183+
### Update All Dependencies
184+
185+
```bash
186+
pip install --upgrade -r requirements.txt
187+
```
188+
189+
### Update Specific Package
190+
191+
```bash
192+
pip install --upgrade package_name
193+
```
194+
195+
### Generate New Requirements Files
196+
197+
```bash
198+
pip freeze > requirements-new.txt
199+
```
200+
201+
## Support
202+
203+
If you encounter issues:
204+
205+
1. Check the troubleshooting section above
206+
2. Verify your Python and package versions
207+
3. Check the project's issue tracker
208+
4. Ensure you're using the recommended Python version (3.8+)

BiasAndFairnessModule/Makefile

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,92 @@
1+
# Virtual environment setup
2+
venv:
3+
python -m venv venv
4+
. venv/bin/activate && pip install --upgrade pip
5+
6+
# Install dependencies
7+
install: venv
8+
. venv/bin/activate && pip install -r requirements.txt
9+
10+
install-dev: venv
11+
. venv/bin/activate && pip install -r requirements-dev.txt
12+
13+
install-exact: venv
14+
. venv/bin/activate && pip install -r requirements-exact.txt
15+
16+
# Code formatting
117
format:
18+
ifdef FILE
19+
black $(FILE)
20+
isort $(FILE)
21+
else
222
black . --exclude '(\.venv|venv)'
323
isort . --skip .venv
24+
endif
425

26+
# Code quality checks
527
lint:
28+
ifdef FILE
29+
flake8 $(FILE)
30+
mypy $(FILE)
31+
pylint $(FILE)
32+
else
633
flake8 . --exclude=.venv
734
mypy . --exclude .venv
835
pylint $(shell find . -type f -name "*.py" ! -path "./.venv/*")
36+
endif
37+
38+
# Testing
39+
test:
40+
. venv/bin/activate && python run_tests.py
41+
42+
# Unit tests
43+
test-unit:
44+
. venv/bin/activate && python src/tests/run_unit_tests.py
45+
46+
test-metrics:
47+
. venv/bin/activate && python src/tests/run_unit_tests.py src.tests.unit.test_metrics
48+
49+
test-registry:
50+
. venv/bin/activate && python src/tests/run_unit_tests.py src.tests.unit.test_metric_registry
51+
52+
# Legacy test commands (for backward compatibility)
53+
test-evaluation:
54+
. venv/bin/activate && python -m src.tests.run_all_tests evaluation
55+
56+
test-config:
57+
. venv/bin/activate && python -m src.tests.run_all_tests config
58+
59+
test-compass:
60+
. venv/bin/activate && python -m src.tests.run_all_tests compass
61+
62+
test-coverage:
63+
. venv/bin/activate && coverage run python run_tests.py
64+
. venv/bin/activate && coverage report
65+
. venv/bin/activate && coverage html
66+
67+
# Development workflow
68+
check: format lint test
69+
70+
# Environment status
71+
status:
72+
@echo "Python version:"
73+
@python --version
74+
@echo "Python path:"
75+
@which python
76+
@echo "NumPy version:"
77+
@python -c "import numpy; print(numpy.__version__)"
78+
@echo "Virtual environment:"
79+
@echo "$$VIRTUAL_ENV"
80+
81+
# Environment check
82+
check-env:
83+
. venv/bin/activate && python check_environment.py
984

10-
check: format lint
85+
# Clean up
86+
clean:
87+
find . -type f -name "*.pyc" -delete
88+
find . -type d -name "__pycache__" -delete
89+
find . -type d -name "*.egg-info" -delete
90+
rm -rf .pytest_cache
91+
rm -rf htmlcov
92+
rm -rf .coverage

0 commit comments

Comments
 (0)