thankyoualways commited on
Commit
6931441
·
verified ·
1 Parent(s): c9c739c

Upload policy_checkpoints/NutAssemblySquare/2024-11-30-00-45-56_E8.2.0b-sq-maxvel1/wandb/run-20241130_031226-mxhmxn6b/files/code/train.py with huggingface_hub

Browse files
policy_checkpoints/NutAssemblySquare/2024-11-30-00-45-56_E8.2.0b-sq-maxvel1/wandb/run-20241130_031226-mxhmxn6b/files/code/train.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ OmegaConf.resolve(cfg)
25
+
26
+ cls = hydra.utils.get_class(cfg._target_)
27
+
28
+ if cfg.training.resume_dir is not None:
29
+ workspace: BaseWorkspace = cls(cfg, output_dir=cfg.training.resume_dir)
30
+ else:
31
+ workspace: BaseWorkspace = cls(cfg)
32
+
33
+ workspace.run()
34
+
35
+ if __name__ == "__main__":
36
+ main()