Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pytest fixtures not being recognised due to incorrect names #26

Merged
merged 9 commits into from
Jun 27, 2023
6 changes: 3 additions & 3 deletions dvc.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ stages:
outs:
- path: data/models/c1_BoW_Sentiment_Model.pkl
hash: md5
md5: 8bc1bbdfd5c667b323c02df7b4683138
md5: 8f65f22eed5c5f896795fa15c0255e1c
size: 39823
- path: data/models/c2_Classifier_Sentiment_Model
hash: md5
Expand All @@ -76,7 +76,7 @@ stages:
deps:
- path: data/models/c1_BoW_Sentiment_Model.pkl
hash: md5
md5: 8bc1bbdfd5c667b323c02df7b4683138
md5: 8f65f22eed5c5f896795fa15c0255e1c
size: 39823
- path: data/models/c2_Classifier_Sentiment_Model
hash: md5
Expand All @@ -100,7 +100,7 @@ stages:
deps:
- path: data/models/c1_BoW_Sentiment_Model.pkl
hash: md5
md5: 8bc1bbdfd5c667b323c02df7b4683138
md5: 8f65f22eed5c5f896795fa15c0255e1c
size: 39823
- path: data/models/c2_Classifier_Sentiment_Model
hash: md5
Expand Down
2 changes: 1 addition & 1 deletion reports/coverage-report.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<coverage version="7.2.7" timestamp="1687793503283" lines-valid="111" lines-covered="29" line-rate="0.2613" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<coverage version="7.2.7" timestamp="1687872627583" lines-valid="111" lines-covered="29" line-rate="0.2613" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.2.7 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
Expand Down
8 changes: 4 additions & 4 deletions reports/mllint_report.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ML Project Report
**Project** | **Details**
--------|--------
Date | Mon, 26 Jun 2023 18:20:01 +0200
Date | Tue, 27 Jun 2023 15:29:22 +0200
Path | `/home/jvandersaag/Documents/REMLA/project/model-training`
Config | `.mllint.yml`
Default | No
Git: Remote URL | `https://github.com/remla23-team08/model-training.git`
Git: Commit | `f0c2bbadefd41a4d93dafe5edae6efbd8a25c6a2`
Git: Branch | `testing`
Git: Commit | `be98a5f0138ff205a06241261f33686bd37a8834`
Git: Branch | `fixture_fix`
Git: Dirty Workspace? | Yes
Number of Python files | 12
Lines of Python code | 286
Expand Down Expand Up @@ -102,7 +102,7 @@ This equates to **33.333333%** of Python files in your project being tests, whic

#### Details — Project passes all of its automated tests — ✅

Congratulations, all **7** tests in your project passed!
Congratulations, all **9** tests in your project passed!

#### Details — Project provides a test coverage report — ❌

Expand Down
3 changes: 2 additions & 1 deletion reports/tests-report.xml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="7" time="40.284" timestamp="2023-06-26T17:31:03.071009" hostname="jvandersaag-hp"><testcase classname="tests.test_features" name="test_distribution" time="0.008" /><testcase classname="tests.test_features" name="test_sentiment" time="0.962" /><testcase classname="tests.test_integration" name="test_load_data" time="0.009" /><testcase classname="tests.test_integration" name="test_preprocessing" time="0.021" /><testcase classname="tests.test_integration" name="test_training" time="0.139" /><testcase classname="tests.test_integration" name="test_evaluation" time="0.167" /><testcase classname="tests.test_modeldevelopment" name="test_nondeterminism_robustness" time="38.248" /></testsuite></testsuites>
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="9" time="62.335" timestamp="2023-06-27T15:29:25.331523" hostname="jvandersaag-hp"><testcase classname="tests.test_MLdevelopment" name="test_nondeterminism_robustness" time="29.319" /><testcase classname="tests.test_MLintegration" name="test_load_data" time="0.009" /><testcase classname="tests.test_MLintegration" name="test_preprocessing" time="0.023" /><testcase classname="tests.test_MLintegration" name="test_training" time="0.104" /><testcase classname="tests.test_MLintegration" name="test_evaluation" time="0.158" /><testcase classname="tests.test_features" name="test_distribution" time="0.014" /><testcase classname="tests.test_features" name="test_sentiment" time="0.942" /><testcase classname="tests.test_monitoring" name="test_training_time" time="15.236" /><testcase classname="tests.test_monitoring" name="test_ram_usage" time="15.639" /></testsuite></testsuites>

24 changes: 12 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
root_path, dataset_path = get_paths()


@pytest.fixture(name="classifier")
def trained_model():
@pytest.fixture(name="trained_model")
def trained_model_():
"""Loads trained model"""
classifier_path = os.path.join(
root_path, "..", "data/models/c2_Classifier_Sentiment_Model"
Expand All @@ -23,25 +23,25 @@ def trained_model():
yield classifier


@pytest.fixture(name="d_set")
def dataset():
@pytest.fixture(name="dataset")
def dataset_():
"""Loads dataset"""
d_set = pd.read_csv(
dataset_path, delimiter="\t", quoting=3, dtype={"Review": object, "Liked": int}
)[:]
yield d_set


@pytest.fixture(name="crps")
def corpus():
@pytest.fixture(name="corpus")
def corpus_():
"""Loads corpus"""
crps_path = os.path.join(root_path, "..", "data/processed/corpus.joblib")
crps = joblib.load(crps_path)
yield crps


@pytest.fixture(name="cv")
def count_vectoriser():
@pytest.fixture(name="count_vectoriser")
def count_vectoriser_():
"""Loads count vectoriser"""
cv = joblib.load(
os.path.join(root_path, "..", "data", "models", "c1_BoW_Sentiment_Model.pkl")
Expand All @@ -59,12 +59,12 @@ def test_data():


@pytest.fixture(name="X")
def X(crps, cv):
def X(corpus, count_vectoriser):
"""Loads full X features"""
return cv.transform(crps).toarray()
return count_vectoriser.transform(corpus).toarray()


@pytest.fixture(name="y")
def y(d_set):
def y(dataset):
"""Loads full y class labels"""
return d_set.iloc[:, -1].values
return dataset.iloc[:, -1].values