RuntimeError: bad object parse
jdekarske opened this issue · 11 comments
Trying to get the record in json format and I get the following error:
File "scripts/record2json.py", line 14, in <module>
match = parse_match(h)
File "/home//.local/lib/python3.10/site-packages/mgz/model/__init__.py", line 94, in parse_match
data = parse(handle)
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 498, in parse
players, mod = parse_players(header, num_players, version)
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 461, in parse_players
players = [parse_player(header, number, num_players) for number in range(num_players)]
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 461, in <listcomp>
players = [parse_player(header, number, num_players) for number in range(num_players)]
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 126, in parse_player
sleeping, end = object_block(data, end, player_number, 1)
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 97, in object_block
objects.append(dict(parse_object(data, pos), index=index))
File "/home//.local/lib/python3.10/site-packages/mgz/fast/header.py", line 63, in parse_object
raise RuntimeError("bad object parse")
RuntimeError: bad object parse
When using Summary I get the following error:
could not fast parse; falling back: bad object parse
I can still get some data with Summary though.
AgeIIDE_Replay_170.zip
have you found any fixes for this? like 20% of the games can't be parsed due to this error ...
If you use Summary
every rec should parse.
But is there a way to still access all the information? Or that these "bad object" can be skipped?
Like I said, Summary
should do the job for you. You're invoking the fast
parser only, which has the failure mode you're observing. If you use Summary
(which starts with fast
and has a fallback to full
--- as the log posted indicates) then everything should work fine (assuming you're parsing supported recs -- MP, no AIs, no scenarios).
ok thanks, but i can get the same information (this issue is not created by me, I’m fetching map, building/techonology and moves information)
Yes you can. On a summary object:
map -> get_map()
actions -> _actions
Oh ok, thank you very much :)
Edit: is there a way to serialize the summary?
Unfortunately you'd have to do that yourself.
Unfortunately you'd have to do that yourself.
how to access the gaia data (from model summary) in full summary (like trees etc.)? i cannot find them in _header
and i have no idea where else to search ...
Unfortunately you'd have to do that yourself.
how to access the gaia data (from model summary) in full summary (like trees etc.)? i cannot find them in
_header
and i have no idea where else to search ...
model
:
m= parse_match(...)
m.gaia # gaia objects found here
full summary
:
s = Summary(...)
s.get_objects() # gaia objects found here w/ `player_number` == `None`