Closed yurivict closed 1 year ago
Hi, I don't at all understand how exactly you are running this. openTSNE doesn't use make
, and you appear to be running a makefile.
The error you're getting is most likely as a result of the Python paths being setup incorrectly. Without knowing how exactly you're running the tests, what your environment is, and why you're even running the tests in the first place, it's hard for me to make any useful suggestions.
@pavlin-policar
The make there is because it is run from the ports framework.
The complete command that runs tests is also there, it begins with "cd".
I am unfamiliar with FreeBSD and the ports framework, but from what I can tell, ports is a FreeBSD package manager, and someone has made openTSNE available there as well. I'm very happy to see that!
Based on https://cgit.freebsd.org/ports/commit/?id=20e55e0cf2b75fa0988ae31c9814d1b8844a5428 (I'm guessing you're the author of that patch), you want to run the unit tests once the package has finished installing?
I'm not entirely sure why this is happening, it could have something to do with Python paths. You may be overwriting the Python path in
+TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
Another thing that I might try would be to run pytest
from the root package directory. This is what I do on my CI servers. pytest
seems to be fairly smart about finding and running tests. In that case, you'd probably need to change
+TEST_WRKSRC= ${WRKSRC}/tests
to
+TEST_WRKSRC= ${WRKSRC}
I see that the tests weren't run before the patch I've been referring to at all. Obviously, I understand you wanting to run tests on the installed package to make sure everything is working correctly, but why the sudden change now?
Tests weren't run before. I only added the 'test' target in this recent commit.
This line:
TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
allows to run openTSNE without installing it, from the stage directory.
Without TEST_WRKSRC= ${WRKSRC}/tests
tests fail like this:
================================================================================================ ERRORS =================================================================================================
_______________________________________________________________________________ ERROR collecting tests/test_affinities.py _______________________________________________________________________________
ImportError while importing test module '/usr/ports/math/py-openTSNE/work-py39/openTSNE-0.7.1/tests/test_affinities.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_affinities.py:10: in <module>
from openTSNE import affinity, nearest_neighbors
openTSNE/__init__.py:1: in <module>
from .tsne import TSNE, TSNEEmbedding, PartialTSNEEmbedding, OptimizationInterrupt
openTSNE/tsne.py:11: in <module>
from openTSNE import _tsne
E ImportError: cannot import name '_tsne' from partially initialized module 'openTSNE' (most likely due to a circular import) (/usr/ports/math/py-openTSNE/work-py39/openTSNE-0.7.1/openTSNE/__init__.py)
And when I install the py39-openTSNE into the system and run pytest from the project's root directory it fails like this:
[yuri@yv /usr/ports/math/py-openTSNE/work-py39/openTSNE-0.7.1]$ pytest
========================================================================================== test session starts ==========================================================================================
platform freebsd13 -- Python 3.9.16, pytest-7.2.1, pluggy-1.0.0
Using --randomly-seed=2922070264
rootdir: /usr/ports/math/py-openTSNE/work-py39/openTSNE-0.7.1
plugins: forked-1.4.0, hypothesis-6.65.2, cov-2.9.0, mypy-plugins-1.10.1, randomly-3.12.0, timeout-2.1.0, rerunfailures-10.1, flaky-3.7.0, xdist-2.5.0, env-0.6.2, freezegun-0.4.2, mock-3.10.0
collected 118 items / 1 error
================================================================================================ ERRORS =================================================================================================
___________________________________________________________________________ ERROR collecting tests/test_nearest_neighbors.py ____________________________________________________________________________
ImportError while importing test module '/usr/ports/math/py-openTSNE/work-py39/openTSNE-0.7.1/tests/test_nearest_neighbors.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_nearest_neighbors.py:17: in <module>
from .test_tsne import check_mock_called_with_kwargs
E ImportError: attempted relative import with no known parent package
=========================================================================================== warnings summary ============================================================================================
../../../../../local/lib/python3.9/site-packages/pytest_freezegun.py:17: 236 warnings
/usr/local/lib/python3.9/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================== short test summary info ========================================================================================
ERROR tests/test_nearest_neighbors.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================================================== 236 warnings, 1 error in 1.40s =====================================================================================
Sorry for the late reply. Is this still an issue or have you managed to track down what the problem was?
I am closing this due to inactivity, but please feel free to reopen this if the problem persists.
@pavlin-policar 1.0.0 still has the same problem.
@yurivict Could you please check if this is still an issue? If so, we need to reopen the issue and figure out what's going on.
Version: 0.7.1 Python-3.9 FreeBSD 13.1