(exp_dir, out_dir)
| 193 | |
| 194 | |
| 195 | def convert_blobs(exp_dir, out_dir): |
| 196 | def convert_blob_value(blob_file_paths): |
| 197 | # Exported values are lists of paths to .bin binary files, representing |
| 198 | # the blobs in each sequence, for each blob sequence in the series. |
| 199 | blobs = [] |
| 200 | for blob_file_path in blob_file_paths: |
| 201 | if os.path.dirname(blob_file_path) != _BLOBS_DIR: |
| 202 | logging.warning( |
| 203 | "Skipping invalid blob file path %r", blob_file_path |
| 204 | ) |
| 205 | continue |
| 206 | with open(os.path.join(exp_dir, blob_file_path), mode="rb") as f: |
| 207 | blobs.append(f.read()) |
| 208 | # Omit dtype; that's fine since read path ignores it anyway. |
| 209 | blob_tensor = tensor_util.make_tensor_proto( |
| 210 | values=blobs, shape=[len(blobs)] |
| 211 | ) |
| 212 | return Summary.Value(tensor=blob_tensor) |
| 213 | |
| 214 | run_to_series = load_run_to_series(os.path.join(exp_dir, _BLOBS_FILE)) |
| 215 | for run, series_list in run_to_series.items(): |
| 216 | w = create_writer_for_run(out_dir, run, "blobs") |
| 217 | for series in series_list: |
| 218 | tag = series["tag"] |
| 219 | summary_metadata = base64.b64decode(series["summary_metadata"]) |
| 220 | points = zip( |
| 221 | series["points"]["steps"], |
| 222 | series["points"]["wall_times"], |
| 223 | series["points"]["blob_file_paths"], |
| 224 | ) |
| 225 | for step, wall_time, blob_file_paths in points: |
| 226 | e = Event(step=step, wall_time=wall_time) |
| 227 | value = convert_blob_value(blob_file_paths) |
| 228 | if value is None: |
| 229 | continue |
| 230 | e.summary.value.append(value) |
| 231 | e.summary.value[0].tag = tag |
| 232 | e.summary.value[0].metadata.MergeFromString(summary_metadata) |
| 233 | w.add_event(e) |
| 234 | w.close() |
| 235 | |
| 236 | |
| 237 | def load_run_to_series(filename): |
no test coverage detected
searching dependent graphs…