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

Attribute error MLRegistry object has not attribute 'endpoints' #36

Open
ashrafuljoypb opened this issue Jul 23, 2023 · 0 comments
Open

Comments

@ashrafuljoypb
Copy link

I am trying to run the code of tests.py so that I can confirm that no issues in the class.
so how can I solve it?
Traceback (most recent call last):
File "/Users/dpashraful/PycharmProjects/Dpml_ex1/dpmlex1/ml/tests.py", line 34, in test_registry
self.assertEqual(len(registry.endpoints), 0)
^^^^^^^^^^^^^^^^^^
AttributeError: 'MLRegistry' object has no attribute 'endpoints'

Here are the tests.py code files code:
import inspect
from django.test import TestCase
from .income_classifier.random_forest import RandomForestClassifier
from .registry import MLRegistry

class MLTests(TestCase):
def test_rf_algorithm(self):
input_data = {
"age": 37,
"workclass": "Private",
"fnlwgt": 34146,
"education": "HS-grad",
"education-num": 9,
"marital-status": "Married-civ-spouse",
"occupation": "Craft-repair",
"relationship": "Husband",
"race": "White",
"sex": "Male",
"capital-gain": 0,
"capital-loss": 0,
"hours-per-week": 68,
"native-country": "United-States"
}
my_alg = RandomForestClassifier()
response = my_alg.compute_prediction(input_data)
self.assertEqual('OK', response['status'])
self.assertTrue('label' in response)
self.assertEqual('<=50K', response['label'])

# add below method to MLTests class:
def test_registry(self):
    registry = MLRegistry()
    self.assertEqual(len(registry.endpoints), 0)
    endpoint_name = "income_classifier"
    algorithm_object = RandomForestClassifier()
    algorithm_name = "random forest"
    algorithm_status = "production"
    algorithm_version = "0.0.1"
    algorithm_owner = "Piotr"
    algorithm_description = "Random Forest with simple pre- and post-processing"
    algorithm_code = inspect.getsource(RandomForestClassifier)
    # add to registry
    registry.add_algorithm(endpoint_name, algorithm_object, algorithm_name,
                           algorithm_status, algorithm_version, algorithm_owner,
                           algorithm_description, algorithm_code)
    # there should be one endpoint available
    self.assertEqual(len(registry.endpoints), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant