MCPcopy Index your code
hub / github.com/tensorflow/tensorboard / _display_ipython

Function _display_ipython

tensorboard/notebook.py:362–407  ·  view source on GitHub ↗
(port, height, display_handle)

Source from the content-addressed store, hash-verified

360
361
362def _display_ipython(port, height, display_handle):
363 import IPython.display
364
365 frame_id = "tensorboard-frame-{:08x}".format(random.getrandbits(64))
366 shell = """
367 <iframe id="%HTML_ID%" width="100%" height="%HEIGHT%" frameborder="0">
368 </iframe>
369 <script>
370 (function() {
371 const frame = document.getElementById(%JSON_ID%);
372 const url = new URL(%URL%, window.location);
373 const port = %PORT%;
374 if (port) {
375 url.port = port;
376 }
377 frame.src = url;
378 })();
379 </script>
380 """
381 proxy_url = os.environ.get("TENSORBOARD_PROXY_URL")
382 if proxy_url is not None:
383 # Allow %PORT% in $TENSORBOARD_PROXY_URL
384 proxy_url = proxy_url.replace("%PORT%", "%d" % port)
385 replacements = [
386 ("%HTML_ID%", html.escape(frame_id, quote=True)),
387 ("%JSON_ID%", json.dumps(frame_id)),
388 ("%HEIGHT%", "%d" % height),
389 ("%PORT%", "0"),
390 ("%URL%", json.dumps(proxy_url)),
391 ]
392 else:
393 replacements = [
394 ("%HTML_ID%", html.escape(frame_id, quote=True)),
395 ("%JSON_ID%", json.dumps(frame_id)),
396 ("%HEIGHT%", "%d" % height),
397 ("%PORT%", "%d" % port),
398 ("%URL%", json.dumps("/")),
399 ]
400
401 for k, v in replacements:
402 shell = shell.replace(k, v)
403 iframe = IPython.display.HTML(shell)
404 if display_handle:
405 display_handle.update(iframe)
406 else:
407 IPython.display.display(iframe)
408
409
410def _display_cli(port, height, display_handle):

Callers

nothing calls this directly

Calls 4

replaceMethod · 0.80
updateMethod · 0.80
displayMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…