-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
58 lines (44 loc) · 1.74 KB
/
run.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
########################################################################################
#
# This run script encapsulates the training and evaluation of a speaker
# recognition model defined by the hydra configuration.
#
# Author(s): Nik Vaessen
########################################################################################
import os
import time
import hydra
from dotenv import load_dotenv
from omegaconf import DictConfig, OmegaConf
from src.util.hydra_resolvers import (
division_resolver,
integer_division_resolver,
random_uuid,
random_experiment_id,
)
################################################################################
# set custom resolvers
OmegaConf.register_new_resolver("divide", division_resolver)
OmegaConf.register_new_resolver("idivide", integer_division_resolver)
OmegaConf.register_new_resolver("random_uuid", random_uuid)
OmegaConf.register_new_resolver("random_name", random_experiment_id)
################################################################################
# wrap around main hydra script
@hydra.main(config_path="config", config_name="train_speaker")
def run(cfg: DictConfig):
# we import here such that tab-completion in bash
# does not need to import everything (which slows it down
# significantly)
from src.main import main
return main(cfg)
################################################################################
# execute hydra application
if __name__ == "__main__":
load_dotenv()
env_var = os.environ
if "SLURM_ARRAY_TASK_ID" in env_var:
job_id = int(env_var["SLURM_ARRAY_TASK_ID"])
sleep_sec = 2 * int(job_id) + 1
print(f"detected slurm array job: sleeping for {sleep_sec} sec")
time.sleep(sleep_sec)
run()