Windows Bug: json.decoder.JSONDecodeError: Invalid \escape
I'm running torch-tb-profiler 0.4.1 on windows and getting the same issue as in #336
Invalid \escape when decoding the JSON. The fix specified in #336 still works although the line is now 131:
Change line 131 in '\path_to_python_installation\Lib\site-packages\torch_tb_profiler\profiler\data.py' to trace_json = json.loads(data.replace(b"\", b"\\"), strict=False)
@davidberard98 has added a fix for this issue in https://github.com/pytorch/kineto/pull/754. @IDGallagher , could you please validate if that fixes your issue?
May need to wait for next release to pick up the fixes.
Can you please try torch-tb-profiler 0.4.3 package?
I think this issue still persists with torch-tb-profiler 0.4.3.
I add this line: str_data = str_data.replace("\\", "\\\\") and it works.
try:
trace_json = json.loads(data, strict=False)
except JSONDecodeError:
with sysio.StringIO() as fout:
str_data = data.decode('utf-8')
str_data = str_data.replace("\\", "\\\\")
# only replace the N/A without surrounding double quote
fout.write(re.sub(r'(?<!")N/A(?!")', "\"N/A\"", str_data))
trace_json = json.loads(fout.getvalue())
logger.warning('Get JSONDecodeError: %s, Re-encode it to temp file' % e.msg)
json_reencode = True