Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Bug: json.decoder.JSONDecodeError: Invalid \escape #750

Open
IDGallagher opened this issue Apr 15, 2023 · 4 comments
Open

Windows Bug: json.decoder.JSONDecodeError: Invalid \escape #750

IDGallagher opened this issue Apr 15, 2023 · 4 comments
Labels
bug Something isn't working plugin PyTorch Profiler TensorBoard Plugin related

Comments

@IDGallagher
Copy link

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)

@aaronenyeshi
Copy link
Member

@davidberard98 has added a fix for this issue in #754. @IDGallagher , could you please validate if that fixes your issue?

@aaronenyeshi aaronenyeshi added the bug Something isn't working label May 9, 2023
@aaronenyeshi
Copy link
Member

May need to wait for next release to pick up the fixes.

@aaronenyeshi aaronenyeshi added the plugin PyTorch Profiler TensorBoard Plugin related label Jun 23, 2023
@aaronenyeshi
Copy link
Member

Can you please try torch-tb-profiler 0.4.3 package?

@diaoenmao
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin PyTorch Profiler TensorBoard Plugin related
Projects
None yet
Development

No branches or pull requests

3 participants