Failing Tests
wergeld opened this issue · comments
I am working through the tutorial and I am running into an issue when trying to run the test items (https://www.deploymachinelearning.com/#algorithms-registry). I am getting errors in apps\endpoints\serializers.py:
from apps.endpoints.models import Endpoint
from apps.endpoints.models import MLAlgorithm
from apps.endpoints.models import MLAlgorithmStatus
from apps.endpoints.models import MLRequest
Each of these throws errors that "Unable to import 'apps.endpoints.models'". I can modify such that it looks like:
from .models import Endpoint
from .models import MLAlgorithm
from .models import MLAlgorithmStatus
from .models import MLRequest
I then had to make a similar change in apps\endpoints\views.py.
I am now faced with same issue in apps\ml\registry.py:
from apps.endpoints.models import Endpoint
from apps.endpoints.models import MLAlgorithm
from apps.endpoints.models import MLAlgorithmStatus
This is the output of the test call:
python manage.py test apps.ml.tests
System check identified no issues (0 silenced).
EERROR: tests (unittest.loader._FailedTest)
ImportError: Failed to import test module: tests
Traceback (most recent call last):
File "C:\Python\Python38\lib\unittest\loader.py", line 154, in loadTestsFromName
module = import(module_name)
File "C:\Users\lrichards\source\repos\my_ml_service\backend\server\apps\ml\tests.py", line 5, in
from .registry import MLRegistry
File "C:\Users\lrichards\source\repos\my_ml_service\backend\server\apps\ml\registry.py", line 1, in
from endpoints.models import Endpoint
ModuleNotFoundError: No module named 'endpoints'
Ran 1 test in 0.003s
FAILED (errors=1)
I am not really sure how to fix this. I am using the same virtual env I setup and editing just the django code in VS Code. The pylint is not yelling at me anymore but the tests fail. If, for example in registry.py i make line 1 be from apps.endpoints.models import Endpoint
it throws very similar error that it cannot find that module.
It seems like there is some sort of relative path thing going on and I cannot seem to figure it out.
System:
Windows 10 Pro
Python 3.8.5 x64
django 2.2.4
Have you tried to add the directory one level higher than apps
to PYTHON_PATH
?
I am not sure where i would add PYTHON_PATH? I have tried doing something like ..apps.endpoints.models
and I got error that I had gone beyond the top level.
I sort of have gotten around this issue on my home computer (versus my work computer) but essentially ignoring anything that pylint says.
Please check below link:
https://datatofish.com/add-python-to-windows-path/
You can also check PYTHON_PATH in the code:
https://stackoverflow.com/questions/1489599/how-do-i-find-out-my-python-path-using-python