Issue reading model with read_model method
Discussed in https://github.com/fumitoh/modelx/discussions/70
Originally posted by cmartinfer September 20, 2022 Hi!
I am trying to read a model created previously with modelx but I have this error.
Can you help me?
As you can see the main issue is with JSONDecode and I can't see where is the error.
m = mx.read_model(select_file(u'Select the model zip file')) Traceback (most recent call last):
File "C:\Users\Programer\Local\Temp\ipykernel_21112\2926388244.py", line 16, in
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize_init_.py", line 136, in read_model return serializer.ModelReader(system, path).read_model(**kwargs)
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1044, in read_model model = self._read_model_inner()
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1061, in _read_model_inner model = self.parse_dir()
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1099, in parse_dir self.parse_dir(nextdir, target=space, spaces=self.result)
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1095, in parse_dir self.parse_source(path_ / name / "init.py", space)
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1144, in parse_source ist = parser.get_instruction()
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1467, in get_instruction value = decoder.decode()
File "C:\Programs\Anaconda3\lib\site-packages\modelx\serialize\serializer_5.py", line 1803, in decode return json.loads(valstr) # such as 3.1415, Infinity
File "C:\Programs\Anaconda3\lib\json_init_.py", line 346, in loads return _default_decoder.decode(s)
File "C:\Programs\Anaconda3\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Programs\Anaconda3\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value
@cmartinfer, did you get this error because you updated modelx? If so, what are the versions before and after the update? The version of modelx the model was saved with can be found in _system.json file in the model.
@fumitoh the model has the same version of modelx, I am working with 0.19.1 version in conda and the _system.json looks like: {"modelx_version": [0, 19, 1], "serializer_version": 5} Thank´s for your attention.
@cmartinfer, it's kind of hard to tell from the error trace. If you're sure you haven't updated any packages, then the cause is likely one of the changes you made to the model since the model was opening no problem.
If you can send me the model personally, I can take a look at it.