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

Function _info_to_string

tensorboard/manager.py:99–127  ·  view source on GitHub ↗

Convert a `TensorBoardInfo` to string form to be stored on disk. The format returned by this function is opaque and should only be interpreted by `_info_from_string`. Args: info: A valid `TensorBoardInfo` object. Raises: ValueError: If any field on `info` is not of the

(info)

Source from the content-addressed store, hash-verified

97
98
99def _info_to_string(info):
100 """Convert a `TensorBoardInfo` to string form to be stored on disk.
101
102 The format returned by this function is opaque and should only be
103 interpreted by `_info_from_string`.
104
105 Args:
106 info: A valid `TensorBoardInfo` object.
107
108 Raises:
109 ValueError: If any field on `info` is not of the correct type.
110
111 Returns:
112 A string representation of the provided `TensorBoardInfo`.
113 """
114 field_name_to_type = typing.get_type_hints(TensorBoardInfo)
115 for key, field_type in field_name_to_type.items():
116 if not isinstance(getattr(info, key), field_type):
117 raise ValueError(
118 "expected %r of type %s, but found: %r"
119 % (key, field_type, getattr(info, key))
120 )
121 if info.version != version.VERSION:
122 raise ValueError(
123 "expected 'version' to be %r, but found: %r"
124 % (version.VERSION, info.version)
125 )
126 json_value = dataclasses.asdict(info)
127 return json.dumps(json_value, sort_keys=True, indent=4)
128
129
130def _info_from_string(info_string):

Callers 1

write_info_fileFunction · 0.85

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…