Compute a `TensorBoardInfo.cache_key` field. The format returned by this function is opaque. Clients may only inspect it by comparing it for equality with other results from this function. Args: working_directory: The directory from which TensorBoard was launched and
(working_directory, arguments, configure_kwargs)
| 171 | |
| 172 | |
| 173 | def cache_key(working_directory, arguments, configure_kwargs): |
| 174 | """Compute a `TensorBoardInfo.cache_key` field. |
| 175 | |
| 176 | The format returned by this function is opaque. Clients may only |
| 177 | inspect it by comparing it for equality with other results from this |
| 178 | function. |
| 179 | |
| 180 | Args: |
| 181 | working_directory: The directory from which TensorBoard was launched |
| 182 | and relative to which paths like `--logdir` and `--db` are |
| 183 | resolved. |
| 184 | arguments: The command-line args to TensorBoard, as `sys.argv[1:]`. |
| 185 | Should be a list (or tuple), not an unparsed string. If you have a |
| 186 | raw shell command, use `shlex.split` before passing it to this |
| 187 | function. |
| 188 | configure_kwargs: A dictionary of additional argument values to |
| 189 | override the textual `arguments`, with the same semantics as in |
| 190 | `tensorboard.program.TensorBoard.configure`. May be an empty |
| 191 | dictionary. |
| 192 | |
| 193 | Returns: |
| 194 | A string such that if two (prospective or actual) TensorBoard |
| 195 | invocations have the same cache key then it is safe to use one in |
| 196 | place of the other. The converse is not guaranteed: it is often safe |
| 197 | to change the order of TensorBoard arguments, or to explicitly set |
| 198 | them to their default values, or to move them between `arguments` |
| 199 | and `configure_kwargs`, but such invocations may yield distinct |
| 200 | cache keys. |
| 201 | """ |
| 202 | if not isinstance(arguments, (list, tuple)): |
| 203 | raise TypeError( |
| 204 | "'arguments' should be a list of arguments, but found: %r " |
| 205 | "(use `shlex.split` if given a string)" % (arguments,) |
| 206 | ) |
| 207 | datum = { |
| 208 | "working_directory": working_directory, |
| 209 | "arguments": arguments, |
| 210 | "configure_kwargs": configure_kwargs, |
| 211 | } |
| 212 | raw = base64.b64encode( |
| 213 | json.dumps(datum, sort_keys=True, separators=(",", ":")).encode("utf-8") |
| 214 | ) |
| 215 | # `raw` is of type `bytes`, even though it only contains ASCII |
| 216 | # characters; we want it to be `str` in both Python 2 and 3. |
| 217 | return str(raw.decode("ascii")) |
| 218 | |
| 219 | |
| 220 | def _get_info_dir(): |
no outgoing calls
no test coverage detected
searching dependent graphs…