pypath icon indicating copy to clipboard operation
pypath copied to clipboard

Failed to import mapping from pypath.utils

Open mauripops opened this issue 1 year ago • 0 comments

Describe the bug Hi, hope you're doing well! Unfortunately, when trying to import mapping from pypath.utils there seems to be a JSONDecodeError. The issue is that Gatewate timeout strings getting appended on the curl request to https://rampdb.nih.gov/api/id-types

To Reproduce Steps to reproduce the behavior:

git clone https://github.com/saezlab/pypath.git
poetry install
poetry shell
python -c "from pypath.utils import mapping"

Note: this occured through installation through pip too on 0.16.5, 0.16.9, 0.16.10

Expected behavior Import to go through without errors.

Traceback

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mauri/work/KG/peace/pypath/pypath/utils/__init__.py", line 20, in <module>
    from . import orthology as homology
  File "/home/mauri/work/KG/peace/pypath/pypath/utils/orthology.py", line 45, in <module>
    import pypath.utils.mapping as mapping
  File "/home/mauri/work/KG/peace/pypath/pypath/utils/mapping.py", line 129, in <module>
    for it in ramp_input.ramp_id_types_2('compound')
  File "/home/mauri/work/KG/peace/pypath/pypath/inputs/ramp.py", line 204, in ramp_id_types_2
    for i in json.loads(c.result)['data']
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Log file Checking the c.result string sent to json the following returns:

<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
{"data":[{"analyteType":"Metabolites","idTypes":"CAS, chebi, chemspider, hmdb, kegg, kegg_glycan, lipidbank, LIPIDMAPS, plantfa, polymer, pubchem, rhea-comp, swisslipids, wikidata"},{"analyteType":"Genes/Proteins","idTypes":"brenda, chebi, EN, ensembl, entrez, gene_symbol, hmdb, ncbiprotein, uniprot, wikidata"}],"function_call":"RaMP::getPrefixesFromAnalytes(\"metabolite\"); RaMP::getPrefixesFromAnalytes(\"gene\")"}

Desktop (please complete the following information):

  • OS: Ubuntu 22.0.04.4
  • Python version: 3.10
  • Version or commit hash 0.16.10

Additional context I guess the required code changes would be in pypath/share/curl.py to avoid this issue from preventing the import.

mauripops avatar Mar 21 '24 08:03 mauripops