-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
72 lines (58 loc) · 1.71 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
run jobs
"""
import os
import shutil
import warnings
import hydra
import wandb
from omegaconf import DictConfig, OmegaConf
from wandb.sdk.wandb_run import Run
from app import AppClass
from utils2 import manager, utils
# enable OpenEXR
os.environ["OPENCV_IO_ENABLE_OPENEXR"] = "1"
@hydra.main(version_base=None, config_path=".")
def main(cfg: DictConfig) -> None:
cfg = manager.customize_cfg(cfg)
os.makedirs(cfg.log.dir, exist_ok=True)
# copy codes
if not os.path.exists(os.path.join(cfg.log.dir, "code")) and not cfg.system.debug:
shutil.copytree(
".",
os.path.join(cfg.log.dir, "code"),
ignore=shutil.ignore_patterns(
"dataset",
"logs",
".*",
"assets",
"slurm_outputs",
"build",
"__pycache__",
cfg.log.root,
),
symlinks=True,
dirs_exist_ok=True,
)
wandb_run: Run = wandb.init(
entity=cfg.log.entity,
project=cfg.log.project,
group=cfg.log.group,
name=cfg.log.name,
job_type=cfg.app.phase,
dir=cfg.log.dir,
config=OmegaConf.to_object(cfg), # type: ignore
mode="offline" if cfg.log.offline else None,
resume="auto",
settings=wandb.Settings(_service_wait=3600),
)
manager.welcome_message(cfg, wandb_run, detailed=False)
manager.seed_everything(cfg.system.seed)
method: AppClass = utils.import_class("app." + cfg.app.cls)(cfg)
method.load_dataset()
method.load_model()
method.process()
manager.finish_message()
if __name__ == "__main__":
warnings.filterwarnings("ignore")
main()