Skip to content

Commit

Permalink
added unit testing framework (#175)
Browse files Browse the repository at this point in the history
* added unit testing framework

* added missing newline

* moved around files

* fixed folder name

* added tests

* readded fairgbm

* clean up

* formatting changes

* more cleanup

* added more tests

* updated readme
  • Loading branch information
valmik-patel authored Apr 3, 2024
1 parent 10a7d11 commit 12996a4
Show file tree
Hide file tree
Showing 42 changed files with 484 additions and 140 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ __pycache__/

.envrc
.manage
.venv
.coverage
.vscode
cov.xml

*.DS_Store*

Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --cov=aequitas
2 changes: 1 addition & 1 deletion requirements/cli.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SQLAlchemy>=1.1.1
tabulate==0.8.2
xhtml2pdf==0.2.2
xhtml2pdf==0.2.15
ohio>=0.2.0
markdown2==2.3.5
3 changes: 2 additions & 1 deletion requirements/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ fairlearn>=0.8.0
hydra-core>=1.3.0
validators>=0.22.0
hyperparameter-tuning>=0.3.1
numpy==1.23.5
numpy==1.23.5
fastparquet==2024.2.0
19 changes: 19 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Create a virtual environment
python3 -m venv .venv

# Activate the virtual environment
source .venv/bin/activate

# Install the required packages
pip install -r ./requirements/main.txt -r ./requirements/cli.txt -r ./requirements/webapp.txt
pip install -e .

pip install pytest pytest-cov

# Run the tests
coverage run -m pytest --cov-report xml:cov.xml --cov-report term

# Deactivate the virtual environment
deactivate
18 changes: 0 additions & 18 deletions src/tests/README.rst

This file was deleted.

120 changes: 0 additions & 120 deletions src/tests/test_bias_report.py

This file was deleted.

13 changes: 13 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Unit Testing in Aequitas

To run unittests locally, you need to run the following commands from the base folder of the project.

The below commans only needs to be run once to give the testing script necessary permission to run

`chmod +x run_tests.sh`

The testing script itself can be run using the following commans

`./run_tests.sh`

The script will run all defined tests in a virtual environment and output the coverage report in the terminal. It will also add an xml file of the coverage report `cov.xml` to the base folder.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions tests/test_artifacts/test_generic/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
label,sensitive,feature1,feature2
1,A,0.5,0.1
0,B,0.2,0.4
1,C,0.7,0.6
0,B,0.3,0.8
1,A,0.9,0.3
1,A,0.5,0.5
0,A,0.2,0.2
1,C,0.7,0.7
0,B,0.3,0.3
1,A,0.9,0.9
Binary file added tests/test_artifacts/test_generic/data.parquet
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/test_artifacts/test_generic/data_test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label,sensitive,feature1,feature2
1,A,0.9,0.9
8 changes: 8 additions & 0 deletions tests/test_artifacts/test_generic/data_train.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
label,sensitive,feature1,feature2
1,A,0.5,0.1
0,B,0.2,0.4
1,C,0.7,0.6
0,B,0.3,0.8
1,A,0.9,0.3
1,A,0.5,0.5
0,A,0.2,0.2
3 changes: 3 additions & 0 deletions tests/test_artifacts/test_generic/data_validation.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
label,sensitive,feature1,feature2
1,C,0.7,0.7
0,B,0.3,0.3
Loading

0 comments on commit 12996a4

Please sign in to comment.