Result of the form `(body, mime_type)`; may raise `NotFound`.
(
self,
ctx,
run,
tag,
is_conceptual,
experiment=None,
limit_attr_size=None,
large_attrs_key=None,
)
| 199 | raise errors.NotFoundError() |
| 200 | |
| 201 | def graph_impl( |
| 202 | self, |
| 203 | ctx, |
| 204 | run, |
| 205 | tag, |
| 206 | is_conceptual, |
| 207 | experiment=None, |
| 208 | limit_attr_size=None, |
| 209 | large_attrs_key=None, |
| 210 | ): |
| 211 | """Result of the form `(body, mime_type)`; may raise `NotFound`.""" |
| 212 | if is_conceptual: |
| 213 | keras_model_config = json.loads( |
| 214 | self._read_blob( |
| 215 | ctx, |
| 216 | experiment, |
| 217 | [metadata.PLUGIN_NAME_KERAS_MODEL], |
| 218 | run, |
| 219 | tag, |
| 220 | ) |
| 221 | ) |
| 222 | graph = keras_util.keras_model_to_graph_def(keras_model_config) |
| 223 | |
| 224 | elif tag is None: |
| 225 | graph_raw = self._read_blob( |
| 226 | ctx, |
| 227 | experiment, |
| 228 | [metadata.PLUGIN_NAME], |
| 229 | run, |
| 230 | metadata.RUN_GRAPH_NAME, |
| 231 | ) |
| 232 | graph = graph_pb2.GraphDef.FromString(graph_raw) |
| 233 | |
| 234 | else: |
| 235 | # Op graph: could be either of two plugins. (Cf. `info_impl`.) |
| 236 | plugins = [ |
| 237 | metadata.PLUGIN_NAME_RUN_METADATA, |
| 238 | metadata.PLUGIN_NAME_RUN_METADATA_WITH_GRAPH, |
| 239 | ] |
| 240 | raw_run_metadata = self._read_blob( |
| 241 | ctx, experiment, plugins, run, tag |
| 242 | ) |
| 243 | run_metadata = config_pb2.RunMetadata.FromString(raw_run_metadata) |
| 244 | graph = graph_util.merge_graph_defs( |
| 245 | [ |
| 246 | func_graph.pre_optimization_graph |
| 247 | for func_graph in run_metadata.function_graphs |
| 248 | ] |
| 249 | ) |
| 250 | |
| 251 | # This next line might raise a ValueError if the limit parameters |
| 252 | # are invalid (size is negative, size present but key absent, etc.). |
| 253 | process_graph.prepare_graph_for_ui( |
| 254 | graph, limit_attr_size, large_attrs_key |
| 255 | ) |
| 256 | return (str(graph), "text/x-protobuf") # pbtxt |
| 257 | |
| 258 | def run_metadata_impl(self, ctx, experiment, run, tag): |