stsievert / salmon

A tool to collect triplet queries
https://docs.stsievert.com/salmon/
BSD 3-Clause "New" or "Revised" License
9 stars 2 forks source link

Salmon throws error when installed with pip #126

Closed crcox closed 2 years ago

crcox commented 2 years ago

I don't have conda or anaconda (or miniconda) on the machine where I want to compute offline embeddings. The documentation indicates that salmon should be installed as:

$ conda env create -f salmon.yml
$ conda activate salmon

I attempted to just ignore that and just install with pip. Attempts to import salmon.triplets.offline fail.

Python 3.6.8 (default, Sep  9 2021, 07:49:02)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import salmon.triplets.offline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chriscox/Research/Behavioral/EmoConcepts/venv/lib64/python3.6/site-packages/salmon/__init__.py", line 2, in <module>                                                                                
    from .backend import app as app_algs
ModuleNotFoundError: No module named 'salmon.backend'

What is the simplest way to generate an offline embedding? I am hesitant to install anaconda alongside my existing package manager.

stsievert commented 2 years ago

This should work; it worked on my own machine now.

$ git clone https://github.com/stsievert/salmon.git
$ cd salmon
$ pip install -r offline.txt  # see file below
$ pip install .
File offline.txt ``` csv numpy>=1.18.0 scipy pandas>=1.0.1 Cython scikit-learn dask>=2021.02.0 distributed>=2021.02.0 torch altair seaborn matplotlib skorch>=0.8.0 fastparquet dask-ml lz4 blosc cytoolz ujson pyyaml pyarrow pytest fastapi[all] rejson cloudpickle bokeh==2.0.1 rejson httpx aiofiles jinja2 redis==3.5.* gunicorn python-multipart starlette-prometheus ```

Let me know if this works for you; if it does, I'll post this example on the documentation with a disclaimer.

crcox commented 2 years ago

Interesting, it's not working for me with the same error as before. While attempting to do this, I began by creating and activating a fresh virtual environment with Python 3.7.3. I upgraded pip, wheel, and setuptools and pulled the latest from salmon github before running pip install -r offline.txt. This completed without error. Then I ran pip install . from within my local clone of the salmon repo while on the main branch, which also completed without error.

Then I started a python interpreter and attempted to import OfflineEmbedding as shown in the docs.

(venv-py373) [chriscox@relearn0 GitHub]$ python
Python 3.7.3 (default, Mar 17 2021, 11:57:12)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from salmon.triplets.offline import OfflineEmbedding
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chriscox/tmp/venv-py373/lib/python3.7/site-packages/salmon/__init__.py", line 2, in <module>
    from .backend import app as app_algs
ModuleNotFoundError: No module named 'salmon.backend'

I repeated the exercise with Python 3.9.9 with the same outcome:

Python 3.9.9 (main, Dec 13 2021, 11:35:51)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from salmon.triplets.offline import OfflineEmbedding
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chriscox/tmp/venv-py3.9.9/lib/python3.9/site-packages/salmon/__init__.py", line 2, in <module>
    from .backend import app as app_algs
ModuleNotFoundError: No module named 'salmon.backend'
stsievert commented 2 years ago

Hm... I can't reproduce. A couple questions:

https://github.com/stsievert/salmon/blob/aa9b703227814178372ed79f5813c8b4559741a1/salmon.yml#L8

crcox commented 2 years ago
[chriscox@relearn0 salmon]$ git pull

Already up to date.

[chriscox@relearn0 salmon]$ cd ~/
[chriscox@relearn0 ~]$ pyenv install 3.8.12
[chriscox@relearn0 ~]$ pyenv rehash
[chriscox@relearn0 tmp]$ cd tmp/
[chriscox@relearn0 tmp]$ pyenv local 3.8.12
[chriscox@relearn0 tmp]$ python -m venv venv-py3.8.12
[chriscox@relearn0 tmp]$ source venv-py3.8.12/bin/activate
(venv-py3.8.12) [chriscox@relearn0 tmp]$ pip install --upgrade pip setuptools wheel
(venv-py3.8.12) [chriscox@relearn0 tmp]$ pip install -r ~/GitHub/salmon/offline.txt
(venv-py3.8.12) [chriscox@relearn0 tmp]$ pip install ~/GitHub/salmon
(venv-py3.8.12) [chriscox@relearn0 tmp]$ which pip

~/tmp/venv-py3.8.12/bin/pip

(venv-py3.8.12) [chriscox@relearn0 tmp]$ which python

~/tmp/venv-py3.8.12/bin/python

(venv-py3.8.12) [chriscox@relearn0 tmp]$ python -V

Python 3.8.12

(venv-py3.8.12) [chriscox@relearn0 tmp]$ python -c 'import salmon; print(salmon.__file__)'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/__init__.py", line 2, in <module>
    from .backend import app as app_algs
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/backend/__init__.py", line 1, in <module>
    from .core import app
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/backend/core.py", line 16, in <module>
    from salmon.frontend.utils import ServerException
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/frontend/__init__.py", line 1, in <module>
    from .private import *
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/frontend/private.py", line 40, in <module>
    from . import plotting
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/frontend/plotting.py", line 17, in <module>
    from .utils import get_logger, image_url
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/frontend/utils.py", line 14, in <module>
    logger = get_logger(__name__)
  File "/home/chriscox/tmp/venv-py3.8.12/lib/python3.8/site-packages/salmon/utils.py", line 32, in get_logger
    assert out.parent.exists()
AssertionError
stsievert commented 2 years ago

Good, I'm glad the exception is in Salmon now.

Try pip install -e . instead of pip install ., a hacky fix for now.

crcox commented 2 years ago

That seems to work! Thank you!

stsievert commented 2 years ago

Note for the future: Salmon writes log files to out/. To allow Salmon to pip-installable, Salmon should write logs to salmon/out/.