OpenNMT Forum

JSON decode error while running server.py

@KishorKP Hello Kishor,

Thanks for your help. So i did some changes to my conf.json file. I ran the command: python3 server.py --ip $IP --port $PORT --url_root $URL_ROOT --config $CONFIG

and got the error:

Traceback (most recent call last):
File “server.py”, line 129, in
debug=args.debug)
File “server.py”, line 24, in start
translation_server.start(config_file)
File “/home/ng/open/OpenNMT-py-master/onmt/translate/translation_server.py”, line 81, in start
self.confs = json.load(f)
File “/usr/lib/python3.6/json/init.py”, line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 14 column 10 (char 339)

Any help in solving this error i will appreciate.
my conf.json file looks like this:
{
“models_root”: “./available_models”,
“models”: [
{
“id”: 100,
“model”: “kmt-model_step_100000.pt”,
“timeout”: 600,
“on_timeout”: “to_cpu”,
“load”: true,
“opt”: {
“gpu”: -1,
“beam_size”: 5
},
“tokenizer”: {
“type”: “pyonmttok”,
“mode”: “conservative”,
}
},{
“model”: “kmt-model_step_100000.pt”,
“timeout”: -1,
“on_timeout”: “unload”,
“model_root”: “./available_models”,
“opt”: {
“batch_size”: 1,
“beam_size”: 5
}
}
]
}

Please add parameters to the conf file for pyonmttok tokenizer…that should work…

Thanks Kishor. So i added paramas to my conf file,
This is my conf file:

{
“models_root”: “./available_models”,
“models”: [
{
“id”: 1,
“model”: “kmt-model_step_100000.pt”,
“timeout”: 600,
“on_timeout”: “to_cpu”,
“load”: true,
“opt”: {
“gpu”: -1,
“beam_size”: 5
},
“tokenizer”: {
“type”: “pyonmttok”,
“mode”: “str”,
“params”: {
“bpe_model_path”:"",
“vocabulary_path”:"",
“vocabulary_threshold”:0,
“sp_model_path”:"",
“sp_nbest_size”:0,
“sp_alpha”:0.1,
“joiner”:“■”,
“joiner_annotate”:false,
“joiner_new”:false,
“spacer_annotate”:false,
“spacer_new”:false,
“case_feature”:false,
“case_markup”:false,
“no_substitution”:false,
“preserve_placeholders”:false,
“preserve_segmented_tokens”:false,
“segment_case”:false,
“segment_numbers”:false,
“segment_alphabet_change”:false,
“segment_alphabet”:[]
}
}
},{
“model”: “kmt-model_step_100000.pt”,
“timeout”: -1,
“on_timeout”: “unload”,
“model_root”: “…/other_models”,
“opt”: {
“batch_size”: 1,
“beam_size”: 10
}
}
]
}

After running , python3 server.py --ip $IP --port $PORT --url_root $URL_ROOT --config $CONFIG
I get the same error as before:
Traceback (most recent call last):
File “server.py”, line 129, in
debug=args.debug)
File “server.py”, line 24, in start
translation_server.start(config_file)
File “/home/ng/open/OpenNMT-py-master/onmt/translate/translation_server.py”, line 81, in start
self.confs = json.load(f)
File “/usr/lib/python3.6/json/init.py”, line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)