dustmaps icon indicating copy to clipboard operation
dustmaps copied to clipboard

Trying to fetch a dust map raises a JSONDecodeError

Open ahlamaq opened this issue 1 year ago • 5 comments

I am trying to download one of the dust maps and encounter the following error, regardless of whether I try to download the map via pip [ eg. dustmaps.bayestar.fetch() ] or manually via setup.py [ eg. python setup.py fetch --map-name=bayestar ]:

File "/anaconda3/lib/python3.11/site-packages/dustmaps/bayestar.py", line 628, in fetch
    fetch_utils.dataverse_download_doi(
  File "/anaconda3/lib/python3.11/site-packages/dustmaps/fetch_utils.py", line 400, in dataverse_download_doi
    metadata = dataverse_search_doi(doi)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/site-packages/dustmaps/fetch_utils.py", line 367, in dataverse_search_doi
    return json.loads(r.text)
           ^^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/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)

This error is actually raised regardless of which dust map I try to download. Any help in resolving this would be much appreciated, since I cannot currently access any of the dust maps from this package.

ahlamaq avatar May 28 '24 09:05 ahlamaq

I am unable to reproduce this error. Can you check if it still occurs for you? I suspect that it had something to do with the Harvard Dataverse returning an invalid JSON response.

gregreen avatar Jul 10 '24 13:07 gregreen

Just to expand on this, it's possible that this is related to Issue #40, which was a problem with the Harvard Dataverse.

gregreen avatar Jul 10 '24 13:07 gregreen

Hi - I see this DOI retrieval issue has recurred for us today (my code initiates the fetch of the dustmaps if they are not already present). This appears to be a recurring problem with the Dataverse server at Harvard. Can anyone confirm that this is a server issue?

Exception Type: JSONDecodeError
Expecting value: line 1 column 1 (char 0)

genghisken avatar Oct 10 '24 10:10 genghisken

Hi, I'm experiencing the same issue. How can I fix this?

I looked into why the metadata can't be dumped into JSON, and it seems the server is responding with a robots.txt file instead of the expected metadata. This only happens when I'm running this code inside a container on Google Cloud Platform (GCP).

Here's the server response that the code is trying to parse as JSON:

User-agent: *
Disallow: /
User-agent: Googlebot
User-agent: soscan (+https://dataone.org/)
Allow: /$
Allow: /dataset.xhtml
Allow: /sitemap*
Allow: /api/datasets/:persistentId/thumbnail
Disallow: /dataverse/*?q
Disallow: /dataverse/*/search
Disallow: /file.xhtml
Disallow: /dataset.xhtml?*&version=&q=
Disallow: /
Disallow: /api
Disallow: /api/*
Crawl-delay: 100
Sitemap: https://dataverse.harvard.edu/sitemap_index.xml
# Created initially using: http://www.mcanerin.com/EN/search-engine/robots-txt.asp
# Verified using: http://tool.motoricerca.info/robots-checker.phtml

nesquivelr avatar Aug 07 '25 22:08 nesquivelr

This looks like an issue with the Harvard Dataverse. One way to get around this problem is to see if you can download the files manually and put them in the directories that dustmaps wants them to be in. Then, you can run fetch() again, and it will detect the presence of the file and skip the download (it may do additional processing on the file, which is why you should still run fetch()).

gregreen avatar Aug 08 '25 12:08 gregreen