uuazed/numerapi

Handle api errors better

Closed this issue · 1 comments

Not sure what the underlying error here is. I am pretty sure it is a time out error. I would recommend adding a simple retry mechanism or at least wrap in a try-catch and print the response

2019-01-22 12:12:51,741 INFO numerapi.numerapi: uploading predictions...
Traceback (most recent call last):
  File "numerai_tools/integration_test.py", line 78, in <module>
    main()
  File "numerai_tools/integration_test.py", line 38, in main
    file_path=file_path, tournament=tournament_number)
  File "/Users/anson/numerai/database-scripts/env/lib/python3.7/site-packages/numerapi/numerapi.py", line 1242, in upload_predictions
    create = self.raw_query(create_query, arguments, authorization=True)
  File "/Users/anson/numerai/database-scripts/env/lib/python3.7/site-packages/numerapi/numerapi.py", line 214, in raw_query
    result = r.json()
  File "/Users/anson/numerai/database-scripts/env/lib/python3.7/site-packages/requests-2.21.0-py3.7.egg/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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)

I just released numerapi 1.4.1 which handles api errors more gracefully. Implementing a retry mechanism is on my to-do list.