Skip to content

Commit c983c03

Browse files
authored
Allow TensorBoard to load in VS Code despite existing MIME type misconfig (microsoft#16203)
1 parent c5e09b2 commit c983c03

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎news/2 Fixes/16072.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Workaround existing MIME type misconfiguration on Windows preventing TensorBoard from loading when starting TensorBoard.

‎pythonFiles/tensorboard_launcher.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import time
22
import sys
33
import os
4-
from tensorboard import default
4+
import mimetypes
55
from tensorboard import program
66

77

88
def main(logdir):
9+
# Environment variable for PyTorch profiler TensorBoard plugin
10+
# to detect when it's running inside VS Code
911
os.environ["VSCODE_TENSORBOARD_LAUNCH"] = "1"
12+
13+
# Work around incorrectly configured MIME types on Windows
14+
mimetypes.add_type("application/javascript", ".js")
15+
16+
# Start TensorBoard using their Python API
1017
tb = program.TensorBoard()
1118
tb.configure(bind_all=False, logdir=logdir)
1219
url = tb.launch()
1320
sys.stdout.write("TensorBoard started at %s\n" % (url))
1421
sys.stdout.flush()
22+
1523
while True:
1624
try:
1725
time.sleep(60)

0 commit comments

Comments
 (0)