How to develop
Opened this issue · 2 comments
Hi, I wanted to further issue #210 and cloned the repository. The only thing I managed to do was building the package with pip install .
as suggested in the readme.
What I would like to do is:
- run any of the unit tests
- run my own script that uses the local clone of openTSNE
- change things in openTSNE and test my changes
However, I am not very experienced in python package development and I have trouble finding out what I'm doing wrong.
I tried running python -m unittest tests/test_utils.py
, but it errored:
E
======================================================================
ERROR: test_utils (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_utils
Traceback (most recent call last):
File "C:\Users\haegeldd\AppData\Local\Programs\Python\Python310\lib\unittest\loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "C:\Users\haegeldd\git\openTSNE\tests\test_utils.py", line 4, in <module>
from openTSNE.utils import clip_point_to_disc
File "C:\Users\haegeldd\git\openTSNE\openTSNE\__init__.py", line 1, in <module>
from .tsne import TSNE, TSNEEmbedding, PartialTSNEEmbedding, OptimizationInterrupt
File "C:\Users\haegeldd\git\openTSNE\openTSNE\tsne.py", line 11, in <module>
from openTSNE import _tsne
ImportError: cannot import name '_tsne' from partially initialized module 'openTSNE' (most likely due to a circular import) (C:\Users\haegeldd\git\openTSNE\openTSNE\__init__.py)
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
(venv)
I also tried to create my own script in the same directory where pyproject.toml
sits:
import openTSNE.tsne
from sklearn import datasets
if __name__ == '__main__':
iris = datasets.load_iris()
x, y = iris["data"], iris["target"]
tsne = openTSNE.tsne.TSNE()
embed = tsne.fit(x)
But running that errors similarly:
$ python myscript.py
Traceback (most recent call last):
File "C:\Users\haegeldd\git\openTSNE\myscript.py", line 1, in <module>
import openTSNE.tsne
File "C:\Users\haegeldd\git\openTSNE\openTSNE\__init__.py", line 1, in <module>
from .tsne import TSNE, TSNEEmbedding, PartialTSNEEmbedding, OptimizationInterrupt
File "C:\Users\haegeldd\git\openTSNE\openTSNE\tsne.py", line 11, in <module>
from openTSNE import _tsne
ImportError: cannot import name '_tsne' from partially initialized module 'openTSNE' (most likely due to a circular import) (C:\Users\haegeldd\git\openTSNE\openTSNE\__init__.py)
(venv)
So yeah, how do I run anything?
Hi David, thanks for your willingness to work on this issue! I have seen this error before, but I've never been able to properly reproduce, diagnose, and fix this issue. If I remember correctly, this happened to me when running tests from Pycharm, but not when I ran it from the command line. This clearly doesn't apply here since you're running it from the command line, but it's probably the same issue. Since I'm replying quite late, if you have been able to resolve the issue, I'd be keen to know how you did it.