NCAR / rda-apps-clients

RDA apps clients. Subdirectories will be organized by language, e.g. python, perl, c++, bash
MIT License
31 stars 19 forks source link

requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #14

Open fenoy opened 1 year ago

fenoy commented 1 year ago

Hello, I am trying to run the following code to do a request:

from rda_apps_clients import rdams_client as rc

control = { 
    'dataset' : 'ds084.1',
    'date':'201609200000/to/201609200000',
    'datetype':'init',
    'param':'V GRD',
    'level':'HTGL:100',
    'oformat':'csv',
    'nlat':-10,
    'slat':-10,
    'elon':45,
    'wlon':45,
    'product':'Analysis'} 

response = rc.submit_json(control)
assert response['code'] == 200
rqst_id = response['result']['request_id']

print(response)

From which i get the following error:

Traceback (most recent call last):
  File "/home/adriafenoy/miniforge3/envs/temp/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/adriafenoy/miniforge3/envs/temp/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/adriafenoy/miniforge3/envs/temp/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/adriafenoy/miniforge3/envs/temp/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)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/adriafenoy/Projectes/antamina/test.py", line 16, in <module>
    response = rc.submit_json(control)
  File "/home/adriafenoy/miniforge3/envs/temp/lib/python3.10/site-packages/rda_apps_clients/rdams_client.py", line 380, in submit_json
    return ret.json()
  File "/home/adriafenoy/miniforge3/envs/temp/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This does not seem normal, as this piece of code is extracted from the official notebook. This error has been seen before in #12 , but the answers do not seem to apply to my case. I wish some of you can help.

Many thanks!

rpconroy commented 1 year ago

Hi,

Thanks for letting us know about this. I think this was caused by a storage issue on our end. Could you try it again and let me know if you're still getting this error?

fenoy commented 1 year ago

Hi,

Thanks for your quick reply. I am still getting the error. I think it has happened in the past but it has been solved in a matter of hours. This time it has been like this for more than one day.

rpconroy commented 1 year ago

Hmm, that's strange. Your same control file appears to be working for me. What version of the client are you using?

from rda_apps_clients import rdams_client as rc
print(rc.__version__)
fenoy commented 1 year ago

I am using version 3.0.0

fenoy commented 1 year ago

It still does not work for me. I noticed that there is mismatch when I do:

pip freeze | grep rda-apps-clients
rda-apps-clients==1.0.1

with respect to what you suggested:

from rda_apps_clients import rdams_client as rc
print(rc.__version__)

which prints 3.0.0

Is there anything wrong regarding my version?

rpconroy commented 1 year ago

Sorry for the delay. It's possible that your authentication is incorrect. I've updated the code to give a more verbose error and you should see it if you run your script again. Do you have a rdams_token.txt file in your working directory?

fenoy commented 1 year ago

The same error is displayed to me. I have a "rdams_token.txt" with the api code I find in https://rda.ucar.edu/accounts/profile/.

rpconroy commented 1 year ago

Do you mind giving this a try one more time? I've added a bit more resilience and error checking to the backend. If it's still not working, could you contact us at rdahelp@ucar.edu, so we can get some more information from you in a less public way? For some reason this issue appears unique to you.

Sorry for all the troubles!