-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrun_sim.py
51 lines (33 loc) · 1.05 KB
/
run_sim.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
import os
import logging
import hydra
import numpy as np
import wandb
from omegaconf import DictConfig, OmegaConf
import torch
from agents.utils.sim_path import sim_framework_path
log = logging.getLogger(__name__)
OmegaConf.register_new_resolver(
"add", lambda *numbers: sum(numbers)
)
torch.cuda.empty_cache()
@hydra.main(config_path="configs", config_name="avoiding_config.yaml")
def main(cfg: DictConfig) -> None:
np.random.seed(cfg.seed)
torch.manual_seed(cfg.seed)
# init wandb logger and config from hydra path
wandb.config = OmegaConf.to_container(cfg, resolve=True, throw_on_missing=True)
run = wandb.init(
project=cfg.wandb.project,
entity=cfg.wandb.entity,
mode="disabled",
config=wandb.config
)
agent = hydra.utils.instantiate(cfg.agents)
# TODO: insert agent.load_pretrained_model() here with relative path
env_sim = hydra.utils.instantiate(cfg.simulation)
env_sim.test_agent(agent)
log.info("done")
wandb.finish()
if __name__ == "__main__":
main()