Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to import mapping from pypath.utils #292

Open
mauripops opened this issue Mar 21, 2024 · 0 comments
Open

Failed to import mapping from pypath.utils #292

mauripops opened this issue Mar 21, 2024 · 0 comments
Labels
bug Problem in the code

Comments

@mauripops
Copy link

mauripops commented Mar 21, 2024

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 mauripops added the bug Problem in the code label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problem in the code
Projects
None yet
Development

No branches or pull requests

1 participant