saezlab / decoupler-py

Python package to perform enrichment analysis from omics data.
https://decoupler-py.readthedocs.io/
GNU General Public License v3.0
157 stars 23 forks source link

dc.get_progeny(organism = 'mouse') fails with ImportError #92

Closed riederd closed 10 months ago

riederd commented 10 months ago

Describe the bug When trying to get the progeny net using dc.get_progeny(organism = 'mouse') I get an import error saying: ImportError: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

However, I installed all (?) relevant packages, as follows:

pip install --upgrade git+https://github.com/saezlab/pypath.git
pip install --upgrade git+https://github.com/saezlab/omnipath.git
pip install --upgrade git+https://github.com/saezlab/decoupler-py.git

To Reproduce

 import logging
 import decoupler as dc

logging.getLogger().setLevel(1)
p = dc.get_progeny(organism = 'mouse')

The above code results in the following output:

Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> import decoupler as dc

>>> 
>>> logging.getLogger().setLevel(1)
>>> p = dc.get_progeny(organism = 'mouse')
DEBUG:root:Attempting to construct classes from the server
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=2048)]>`
INFO:root:Downloading data from `https://omnipathdb.org/queries/enzsub?format=json`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /queries/enzsub?format=json HTTP/1.1" 200 976
DEBUG:root:Caching result to `<NoopCache>['b6a54633e6816d5af773b5c4a03a9044']`
DEBUG:root:Attempting to construct classes from the server
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=2048)]>`
INFO:root:Downloading data from `https://omnipathdb.org/queries/interactions?format=json`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /queries/interactions?format=json HTTP/1.1" 200 3991
DEBUG:root:Caching result to `<NoopCache>['6d9d075bd52bac2bdc9d203f3a9a63af']`
DEBUG:root:Attempting to construct classes from the server
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=2048)]>`
INFO:root:Downloading data from `https://omnipathdb.org/queries/complexes?format=json`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /queries/complexes?format=json HTTP/1.1" 200 487
DEBUG:root:Caching result to `<NoopCache>['fc020dc1d6e487cd1decf87b5dde21ef']`
DEBUG:root:Attempting to construct classes from the server
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=2048)]>`
INFO:root:Downloading data from `https://omnipathdb.org/queries/annotations?format=json`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /queries/annotations?format=json HTTP/1.1" 200 1563
DEBUG:root:Caching result to `<NoopCache>['e4d417efb364f83ab243221072bb9c7c']`
DEBUG:root:Attempting to construct classes from the server
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=2048)]>`
INFO:root:Downloading data from `https://omnipathdb.org/queries/intercell?format=json`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /queries/intercell?format=json HTTP/1.1" 200 1861
DEBUG:root:Caching result to `<NoopCache>['caa0db78f8b33ac0e9b696bebdd7c5be']`
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<NoopCache>, autoload=True, convert_dtypes=True, num_retries=0, timeout=0.1, chunk_size=1024)]>`
INFO:root:Downloading data from `https://omnipathdb.org/about?format=text`
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): omnipathdb.org:443
DEBUG:urllib3.connectionpool:https://omnipathdb.org:443 "GET /about?format=text HTTP/1.1" 200 196
DEBUG:root:Not caching the results
DEBUG:root:Initialized `<Downloader[options=Options(url='https://omnipathdb.org', license=None, cache=<FileCache[size=1, path='/home/rieder/.cache/omnipathdb']>, autoload=True, convert_dtypes=True, num_retries=3, timeout=600.0, chunk_size=8196)]>`
INFO:root:Downloading annotations for all proteins from the following resources: `['PROGENy']`
DEBUG:root:Unable to perform parameter validation for `resources`, haystack is empty
DEBUG:root:Found data in cache `<FileCache[size=1, path='/home/rieder/.cache/omnipathdb']>['0c5f7f75a74a2bdadf2e7efebe01ff1f']`
WARNING:root:Traceback (most recent call last):
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/decoupler/omnip.py", line 647, in translate_net
    import pypath
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/__init__.py", line 34, in <module>
    from pypath._metadata import __version__, __author__, __license__
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/_metadata.py", line 83, in <module>
    metadata = get_metadata()
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/_metadata.py", line 56, in get_metadata
    'name': pyproject['tool']['poetry']['name'],
KeyError: 'poetry'

WARNING:root:pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git
/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/decoupler/_misc.py:22: UserWarning: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git
  warnings.warn(msg)
Traceback (most recent call last):
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/decoupler/omnip.py", line 647, in translate_net
    import pypath
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/__init__.py", line 34, in <module>
    from pypath._metadata import __version__, __author__, __license__
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/_metadata.py", line 83, in <module>
    metadata = get_metadata()
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/pypath/_metadata.py", line 56, in get_metadata
    'name': pyproject['tool']['poetry']['name'],
KeyError: 'poetry'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/decoupler/omnip.py", line 214, in get_progeny
    p = translate_net(
  File "/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/decoupler/omnip.py", line 671, in translate_net
    raise ImportError(msg)
ImportError: pypath-omnipath is not installed. Please install it with: pip install git+https://github.com/saezlab/pypath.git

Expected behavior dc.get_progeny(organism = 'mouse') should return the progeny net for mouse.

System

riederd commented 10 months ago

I could work around the issue by manually downloading the project.toml [1] file from pypath to the pypath package dir in my conda env [2]

Shouldn't this file by included in the pypath package?

[1] https://github.com/saezlab/pypath/blob/master/pyproject.toml [2] ~/.conda/envs/scirpy/lib/python3.10/site-packages/pypath

deeenes commented 10 months ago

Hi @riederd, thanks for reporting! This is a very recent issue that I introduced just a few days ago, and will be gone hopefully very soon. A fast solution might be to downgrade pypath. Or wait until today/tomorrow when I will be ready fixing this. Very interesting that moving pyproject.toml into the directory of the installed Python package does anything: that file definitely shouldn't be there, and is supposed to have no function in that directory.

riederd commented 10 months ago

Thanks for the suggestions, as it works for now, I'll just wait until fixed.

deeenes commented 10 months ago

Hi @riederd, Over the last few days pypath had an issue which made it fail on import in many situations. Now this is supposed to be resolved, and I would expect Progeny mouse to work in decoupler, if you update pypath-omnipath to its latest version:

pip install --upgrade git+https://github.com/saezlab/pypath.git

If you still experience issues, please also share the pypath log or any error that happens at importing pypath:

import pypath
pypath.log()
# or path to the log:
pypath.session.log.fname
riederd commented 10 months ago

Hi, many thanks for your effort. The issue seems to be fixed now.