Repository: AI-SDC/SACRO-ML (language: python)

Issue:
13 remove underscore from module
Closes #13 
- Renamed the data preprocessing code so that it no longer has an underscore in the name.
- Updated references to this in the code and docs
- Fixed issues with the docs for the attacks not being generated
- added instructions to CONTRIBUTION.md for generating the docs locally in linux and windows


Discussion / hints:

Fix patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 89f29d4d..16a87846 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -35,7 +35,7 @@ Data Interface
  
 An example Python Notebook is available  `Here <https://github.com/jim-smith/GRAIMatter/blob/main/WP2/wrapper/wrapper-concept.ipynb>`_
  
-.. automodule:: data_preprocessing.datainterface
+.. automodule:: preprocessing.loaders
    :members:
 ```
 
@@ -131,6 +131,18 @@ It is possible to include images like this
     :alt: alternate text
 ```
 
+Generating docs locally
+=======================
+
+It is useful to be able to generate your docs locally (to check for bugs etc)
+
+In linux, navigate to the `docs` folder and then issue the command
+`make html`
+
+In windows, navigate to the `docs` folder than then issue the command
+`sphinx-build source _build`
+
+The generated html will be in the folder `docs/_build` and can be opened in any browser.
 
 
 
diff --git a/docs/source/attacks.rst b/docs/source/attacks.rst
index 65ade9ef..7944d622 100644
--- a/docs/source/attacks.rst
+++ b/docs/source/attacks.rst
@@ -1,7 +1,13 @@
 Attacks
 =======
 
-.. automodule:: metrics.py
-.. automodule:: mia_extremecase.py
-.. automodule:: worst_case_attack.py
-.. automodule:: report.py
+.. automodule:: attacks.metrics
+    :members:
+.. automodule:: attacks.mia_extremecase
+    :members:
+.. automodule:: attacks.worst_case_attack
+    :members:
+.. automodule:: attacks.report
+    :members:
+.. automodule:: attacks.likelihood_test
+    :members:
diff --git a/docs/source/datainterface.rst b/docs/source/datainterface.rst
deleted file mode 100644
index f0781fbb..00000000
--- a/docs/source/datainterface.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-
-Data Interface
-================
-
-      
-.. automodule:: data_preprocessing.data_interface
-   :members:
-
diff --git a/docs/source/index.rst b/docs/source/index.rst
index e2d5ed78..474f434a 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -16,7 +16,7 @@ This is the class and function reference for safemodel.
    :caption: Contents:
    
    introduction
-   datainterface
+   preprocessing
    attacks
    safemodel
    safedecisiontree
diff --git a/docs/source/preprocessing.rst b/docs/source/preprocessing.rst
new file mode 100644
index 00000000..5381e267
--- /dev/null
+++ b/docs/source/preprocessing.rst
@@ -0,0 +1,8 @@
+
+Preprocessing
+================
+
+      
+.. automodule:: preprocessing.loaders
+   :members:
+
diff --git a/data_preprocessing/data_interface.py b/preprocessing/loaders.py
similarity index 99%
rename from data_preprocessing/data_interface.py
rename to preprocessing/loaders.py
index 36976c24..7704be50 100644
--- a/data_preprocessing/data_interface.py
+++ b/preprocessing/loaders.py
@@ -1,5 +1,5 @@
 '''
-data_interface.py
+loaders.py
 A set of useful handlers to pull in datasets common to the project and perform the appropriate
 pre-processing
 '''
diff --git a/safemodel/classifiers/__pycache__/__init__.cpython-39.pyc b/safemodel/classifiers/__pycache__/__init__.cpython-39.pyc
deleted file mode 100644
index 79a6d87d..00000000
Binary files a/safemodel/classifiers/__pycache__/__init__.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/dp_svc.cpython-39.pyc b/safemodel/classifiers/__pycache__/dp_svc.cpython-39.pyc
deleted file mode 100644
index b0d6571b..00000000
Binary files a/safemodel/classifiers/__pycache__/dp_svc.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/rf_binned_output_probs.cpython-39.pyc b/safemodel/classifiers/__pycache__/rf_binned_output_probs.cpython-39.pyc
deleted file mode 100644
index 7b708010..00000000
Binary files a/safemodel/classifiers/__pycache__/rf_binned_output_probs.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/safedecisiontreeclassifier.cpython-39.pyc b/safemodel/classifiers/__pycache__/safedecisiontreeclassifier.cpython-39.pyc
deleted file mode 100644
index 8d3d1d08..00000000
Binary files a/safemodel/classifiers/__pycache__/safedecisiontreeclassifier.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/safekeras.cpython-39.pyc b/safemodel/classifiers/__pycache__/safekeras.cpython-39.pyc
deleted file mode 100644
index 119df21d..00000000
Binary files a/safemodel/classifiers/__pycache__/safekeras.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/saferandomforestclassifier.cpython-39.pyc b/safemodel/classifiers/__pycache__/saferandomforestclassifier.cpython-39.pyc
deleted file mode 100644
index a0b9885a..00000000
Binary files a/safemodel/classifiers/__pycache__/saferandomforestclassifier.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/safesvc.cpython-39.pyc b/safemodel/classifiers/__pycache__/safesvc.cpython-39.pyc
deleted file mode 100644
index 876dff0e..00000000
Binary files a/safemodel/classifiers/__pycache__/safesvc.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/__pycache__/safetf.cpython-39.pyc b/safemodel/classifiers/__pycache__/safetf.cpython-39.pyc
deleted file mode 100644
index 0ea5ed55..00000000
Binary files a/safemodel/classifiers/__pycache__/safetf.cpython-39.pyc and /dev/null differ
diff --git a/safemodel/classifiers/rf_binned_output_probs.py b/safemodel/classifiers/rf_binned_output_probs.py
index ae078c6e..3953c1b7 100644
--- a/safemodel/classifiers/rf_binned_output_probs.py
+++ b/safemodel/classifiers/rf_binned_output_probs.py
@@ -75,7 +75,7 @@ def original_predict_proba(self, X: np.ndarray) -> np.ndarray:
 
 if __name__ == '__main__':
     rr = RFNoiseOutput(noise_var=10)
-    from data_preprocessing.data_interface import get_data_sklearn
+    from preprocessing.loaders import get_data_sklearn
     X, y = get_data_sklearn('mimic2-iaccd')
     rr.fit(X.values, y.values.flatten())
 


Test patch:
diff --git a/.github/workflows/lint-test-on-push.yml b/.github/workflows/lint-test-on-push.yml
index fe749a67..b44d1131 100644
--- a/.github/workflows/lint-test-on-push.yml
+++ b/.github/workflows/lint-test-on-push.yml
@@ -19,10 +19,11 @@ jobs:
       - name: Install dependencies
         run: |
           python -m pip install --upgrade pip
+          pip install pylint pytest
           if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
       - name: Lint with pylint
         run: |
           pylint **/*.py --fail-under 7
-      - name: Test with unittest
+      - name: Test with pytest
         run: |
-          python -m unittest discover tests
\ No newline at end of file
+          pytest .
diff --git a/tests/test_data_interface.py b/tests/test_data_interface.py
index 33f2626e..93da1dee 100644
--- a/tests/test_data_interface.py
+++ b/tests/test_data_interface.py
@@ -4,7 +4,7 @@
 
 import unittest
 import pandas as pd
-from data_preprocessing.data_interface import get_data_sklearn, UnknownDataset  # pylint: disable = import-error
+from preprocessing.loaders import get_data_sklearn, UnknownDataset  # pylint: disable = import-error
 
 
 class TestLoaders(unittest.TestCase):