-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunch_tensorboard.py
executable file
·45 lines (35 loc) · 1.14 KB
/
launch_tensorboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
# This script takes a flat directory of tensorboard logs and restructures
# it so tensorboard only loads specified experiments.
import shutil
import re
import os
import os.path as pth
import glob
from subprocess import Popen
PORT = 6077
SOURCE_DIR = 'logs/'
TARGET_DIR = 'logs/tboard_events/'
INCLUDE_DEBUG = True
include_patterns = [
'exp18.*',
]
if not INCLUDE_DEBUG:
for i in range(len(include_patterns)):
include_patterns[i] += '\.\d+$'
include_patterns = [re.compile(pt) for pt in include_patterns]
print(f'refreshing target directory {TARGET_DIR}... ', end='')
shutil.rmtree(TARGET_DIR)
os.makedirs(TARGET_DIR)
print('done')
print('creating symlinks... ', end='')
for name in glob.glob(pth.join(SOURCE_DIR, '*')):
basename = pth.basename(name)
for pattern in include_patterns:
match = pattern.match(basename)
if match:
dest = pth.relpath(name, TARGET_DIR)
src = pth.join(TARGET_DIR, basename)
os.symlink(dest, src)
print('done')
Popen(f'tensorboard --logdir {TARGET_DIR} --port {PORT}', shell=True).wait()