Internal version of `display`. Args: port: As with `display`. height: As with `display`. print_message: True to print which TensorBoard instance was selected for display (if applicable), or False otherwise. display_handle: If not None, an IPython display handle i
(port=None, height=None, print_message=False, display_handle=None)
| 259 | |
| 260 | |
| 261 | def _display(port=None, height=None, print_message=False, display_handle=None): |
| 262 | """Internal version of `display`. |
| 263 | |
| 264 | Args: |
| 265 | port: As with `display`. |
| 266 | height: As with `display`. |
| 267 | print_message: True to print which TensorBoard instance was selected |
| 268 | for display (if applicable), or False otherwise. |
| 269 | display_handle: If not None, an IPython display handle into which to |
| 270 | render TensorBoard. |
| 271 | """ |
| 272 | if height is None: |
| 273 | height = 800 |
| 274 | |
| 275 | if port is None: |
| 276 | infos = manager.get_all() |
| 277 | if not infos: |
| 278 | raise ValueError( |
| 279 | "Can't display TensorBoard: no known instances running." |
| 280 | ) |
| 281 | else: |
| 282 | info = max(manager.get_all(), key=lambda x: x.start_time) |
| 283 | port = info.port |
| 284 | else: |
| 285 | infos = [i for i in manager.get_all() if i.port == port] |
| 286 | info = max(infos, key=lambda x: x.start_time) if infos else None |
| 287 | |
| 288 | if print_message: |
| 289 | if info is not None: |
| 290 | message = ( |
| 291 | "Selecting TensorBoard with {data_source} " |
| 292 | "(started {delta} ago; port {port}, pid {pid})." |
| 293 | ).format( |
| 294 | data_source=manager.data_source_from_info(info), |
| 295 | delta=_time_delta_from_info(info), |
| 296 | port=info.port, |
| 297 | pid=info.pid, |
| 298 | ) |
| 299 | print(message) |
| 300 | else: |
| 301 | # The user explicitly provided a port, and we don't have any |
| 302 | # additional information. There's nothing useful to say. |
| 303 | pass |
| 304 | |
| 305 | fn = { |
| 306 | _CONTEXT_COLAB: _display_colab, |
| 307 | _CONTEXT_IPYTHON: _display_ipython, |
| 308 | _CONTEXT_NONE: _display_cli, |
| 309 | }[_get_context()] |
| 310 | return fn(port=port, height=height, display_handle=display_handle) |
| 311 | |
| 312 | |
| 313 | def _display_colab(port, height, display_handle): |
no test coverage detected
searching dependent graphs…