Launch and display a TensorBoard instance as if at the command line. Args: args_string: Command-line arguments to TensorBoard, to be interpreted by `shlex.split`: e.g., "--logdir ./logs --port 0". Shell metacharacters are not supported: e.g., "--logdir 2>&1" will p
(args_string)
| 118 | |
| 119 | |
| 120 | def start(args_string): |
| 121 | """Launch and display a TensorBoard instance as if at the command line. |
| 122 | |
| 123 | Args: |
| 124 | args_string: Command-line arguments to TensorBoard, to be |
| 125 | interpreted by `shlex.split`: e.g., "--logdir ./logs --port 0". |
| 126 | Shell metacharacters are not supported: e.g., "--logdir 2>&1" will |
| 127 | point the logdir at the literal directory named "2>&1". |
| 128 | """ |
| 129 | context = _get_context() |
| 130 | try: |
| 131 | import IPython |
| 132 | import IPython.display |
| 133 | except ImportError: |
| 134 | IPython = None |
| 135 | |
| 136 | if context == _CONTEXT_NONE: |
| 137 | handle = None |
| 138 | print("Launching TensorBoard...") |
| 139 | else: |
| 140 | handle = IPython.display.display( |
| 141 | IPython.display.Pretty("Launching TensorBoard..."), |
| 142 | display_id=True, |
| 143 | ) |
| 144 | |
| 145 | def print_or_update(message): |
| 146 | if handle is None: |
| 147 | print(message) |
| 148 | else: |
| 149 | handle.update(IPython.display.Pretty(message)) |
| 150 | |
| 151 | parsed_args = shlex.split(args_string, comments=True, posix=True) |
| 152 | start_result = manager.start(parsed_args) |
| 153 | |
| 154 | if isinstance(start_result, manager.StartLaunched): |
| 155 | _display( |
| 156 | port=start_result.info.port, |
| 157 | print_message=False, |
| 158 | display_handle=handle, |
| 159 | ) |
| 160 | |
| 161 | elif isinstance(start_result, manager.StartReused): |
| 162 | template = ( |
| 163 | "Reusing TensorBoard on port {port} (pid {pid}), started {delta} ago. " |
| 164 | "(Use '!kill {pid}' to kill it.)" |
| 165 | ) |
| 166 | message = template.format( |
| 167 | port=start_result.info.port, |
| 168 | pid=start_result.info.pid, |
| 169 | delta=_time_delta_from_info(start_result.info), |
| 170 | ) |
| 171 | print_or_update(message) |
| 172 | _display( |
| 173 | port=start_result.info.port, |
| 174 | print_message=False, |
| 175 | display_handle=None, |
| 176 | ) |
| 177 |
no test coverage detected
searching dependent graphs…