-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (49 loc) · 1.64 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import subprocess
import warnings
from tensorboard import program
from dotenv import load_dotenv
class EnvVariables:
def __init__(self):
self.port = os.environ.get("PORT")
self.s3_bucket_name = os.environ.get("S3_BUCKET_NAME")
self.logdir = os.environ.get("LOGDIR")
self.s3_endpoint = os.environ.get("S3_ENDPOINT")
self.s3_verify_ssl = os.environ.get("S3_VERIFY_SSL")
self.s3_use_https = os.environ.get("S3_USE_HTTPS")
self.aws_region = os.environ.get("AWS_REGION")
self.aws_access_key_id = os.environ.get("AWS_ACCESS_KEY_ID")
self.aws_secret_access_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
self.check_missing_vars()
def check_missing_vars(self):
missing_vars = [var for var in vars(self) if getattr(self, var) is None]
if missing_vars:
warnings.warn(
f"WARNING: The following environment variables are missing: {', '.join(missing_vars)}"
)
if __name__ == "__main__":
load_dotenv()
vars = EnvVariables()
s3_path = f"s3://{vars.s3_bucket_name}/{vars.logdir}"
cmd = [
"tensorboard",
"--logdir",
s3_path,
"--port",
vars.port,
"--bind_all",
"--reload_multifile",
"true",
"--reload_multifile_inactive_secs",
"3",
"--purge_orphaned_data",
"true",
"--detect_file_replacement",
"true",
"serve",
]
print("running:", " ".join(cmd))
# Launch TensorBoard using subprocess
process = subprocess.Popen(cmd)
# Wait for TensorBoard to finish
process.wait()