forked from embodied-generalist/embodied-generalist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·37 lines (28 loc) · 985 Bytes
/
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
import os
from datetime import datetime
import hydra
from accelerate.logging import get_logger
import common.io_utils as iu
from common.misc import rgetattr
from trainer.build import build_trainer
logger = get_logger(__name__)
@hydra.main(config_path='configs', config_name='default', version_base=None)
def main(cfg):
os.environ['TOKENIZERS_PARALLELISM'] = 'true' # suppress hf tokenizer warning
naming_keys = [cfg.name]
for name in cfg.naming_keywords:
key = str(rgetattr(cfg, name))
if key:
naming_keys.append(key)
exp_name = '_'.join(naming_keys)
# Record the experiment
cfg.exp_dir = os.path.join(
cfg.base_dir, exp_name,
f"{datetime.now().strftime('%Y-%m-%d-%H:%M:%S')}" if 'time' in cfg.naming_keywords else ""
)
iu.make_dir(cfg.exp_dir)
iu.save_yaml(cfg, os.path.join(cfg.exp_dir, 'config.json'))
trainer = build_trainer(cfg)
trainer.run()
if __name__ == '__main__':
main()