-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (26 loc) · 910 Bytes
/
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
import pytorch_lightning as pl
import yaml
from src.tester import check
from src.trainer import train
# Entrypoint from the docker container
# this files calls the trainer with
# the given conf mounted in /conf
if __name__ == "__main__":
# Reproducibility
pl.seed_everything(42, workers=True)
# Reading YAML conf (/conf needs to be mounted in Docker Container)
with open("./conf/configuration.yaml", "r") as f:
conf = yaml.safe_load(f)
# Phase action defined by conf either train or test
if conf["phase"] == 'train':
# Run trainer
train(conf)
elif conf["phase"] == 'test':
# Run tester
check(conf)
else:
raise ValueError(
"Only supported phases are: train and test however phase {} "
"was given, review configuration with path /experiment/phase "
"in YAML".format(conf["phase"])
)