Skip to content

Commit

Permalink
fix: Add workaround for warning from nbconvert.
Browse files Browse the repository at this point in the history
When executing a notebook during export to HTML, `nbconvert` prints the following warning:
```
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
```

The workaround is to temporarily set the environment variable according to the suggestion in the warning.
It can be safely disabled since we do not need debugging.
  • Loading branch information
mbelak-dtml committed Jul 25, 2023
1 parent 8b29829 commit 0c78634
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions edvart/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Standard imports
import base64
import logging
import os
import pickle
from abc import ABC
from typing import List, Optional, Tuple, Union
Expand Down Expand Up @@ -225,7 +226,14 @@ def _export_html(

html_exporter = nbconvert.HTMLExporter(**html_exp_kwargs)

# Workaround for a warning from `nbconvert` regarding debugging
# and frozen modules. We are not debugging, so we can safely ignore it.
disable_validation_env_var_name = "PYDEVD_DISABLE_FILE_VALIDATION"
env_original = os.environ.copy()
os.environ[disable_validation_env_var_name] = "1"

html = html_exporter.from_notebook_node(nb)[0]
os.environ = env_original

# Save HTML to file
with open(html_filepath, "w") as html_file:
Expand Down

0 comments on commit 0c78634

Please sign in to comment.