thankyoualways commited on
Commit
5ea53de
·
verified ·
1 Parent(s): 153ef53

Upload policy_checkpoints/NutAssemblySquare/v0/wandb/run-20241111_213035-kyr0wjsm/files/code/train.py with huggingface_hub

Browse files
policy_checkpoints/NutAssemblySquare/v0/wandb/run-20241111_213035-kyr0wjsm/files/code/train.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ # use line-buffering for both stdout and stderr
3
+ sys.stdout = open(sys.stdout.fileno(), mode='w', buffering=1)
4
+ sys.stderr = open(sys.stderr.fileno(), mode='w', buffering=1)
5
+
6
+ import hydra
7
+ import pathlib
8
+
9
+ from omegaconf import OmegaConf
10
+
11
+ from adaflow.workspace.base_workspace import BaseWorkspace
12
+
13
+ # allows arbitrary python code execution in configs using the ${eval:''} resolver
14
+ OmegaConf.register_new_resolver("eval", eval, replace=True)
15
+
16
+ @hydra.main(
17
+ version_base=None,
18
+ config_path=str(pathlib.Path(__file__).parent.joinpath(
19
+ 'adaflow','config'))
20
+ )
21
+ def main(cfg: OmegaConf):
22
+ # resolve immediately so all the ${now:} resolvers
23
+ # will use the same time.
24
+ # save dict as json
25
+ OmegaConf.resolve(cfg)
26
+ cls = hydra.utils.get_class(cfg._target_)
27
+ if cfg.training.resume_dir is not None:
28
+ workspace: BaseWorkspace = cls(cfg, output_dir=cfg.training.resume_dir)
29
+ else:
30
+ workspace: BaseWorkspace = cls(cfg)
31
+
32
+ workspace.run()
33
+
34
+ if __name__ == "__main__":
35
+ main()