train.py error in ibm watson retrieve and rank service setup

332 Views Asked by At

I'm following the retrieve and rank tutorial and everything is good until the train.py script - I get error "ValueError: No JSON object could be decoded"

my command line with masked creds:

python ./train.py -u "zzzz":"ssss" -i /Users/nik/Downloads/cranfield_gt.csv -c "zzzz" -x example_collection -n "example_ranker"

result:

    Input file is /Users/nik/Downloads/cranfield_gt.csv
Solr cluster is zzzz
Solr collection is example_collection
Ranker name is example_ranker
Rows per query 10
Generating training data...
Command:
curl -k -s  -u zzzz:ssss -d "q=what similarity laws must be obeyed when constructing aeroelastic models of heated high speed aircraft.&gt=184,3,29,3,31,3,12,2,51,2,102,2,13,1,14,1,15,1,57,3,378,3,859,3,185,2,30,2,37,2,52,1,142,1,195,1,875,3,56,2,66,2,95,2,462,1,497,2,858,2,876,2,879,2,880,2,486,0&generateHeader=true&rows=10&returnRSInput=true&wt=json" "https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/zzzz/solr/example_collection/fcselect"
Response:

Traceback (most recent call last):
  File "./train.py", line 88, in <module>
    parsed_json = json.loads(output)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Ideas why I get this error and most of all how to resolve it?

Thanks, Nik

1

There are 1 best solutions below

0
On BEST ANSWER

OK this is one of those late night experiences .. I was convinced that I did uploaded my cranfield_data.json file, but checking it today showed me that I didn't. Runnig the script today to upload it again and seeing the confirmation was the key.

After that I've repeated the train.py and everything worked!

I hope this helps someone else too.

BTW just before uploading the first time I've tried to update and recompile curl. It seems that I did not configure it to use https and I guess I did not payed attention when I executed the curl to upload cranfield_data.json the first time. Today I saw the error "protocol "https" not supported" and this helped me understand what happened before. Restoring the original curl on my mac resolved the issue.