1
+ from pathlib import Path
2
+ import simple_parsing , logging , os
3
+ from dataclasses import dataclass
4
+
5
+ from nb_helpers .run import run_one as _run_one
6
+
7
+ # logger.logger.setLevel(logging.DEBUG)
8
+
9
+ import weave
10
+
11
+ @weave .op
12
+ def run_one (
13
+ fname : str ,
14
+ pip_install : bool = False ,
15
+ create_github_issue : bool = False ,
16
+ repo : str = None ,
17
+ owner : str = None ,
18
+ ) -> dict :
19
+ "Run one nb and store the tb if it fails"
20
+ run_status , runtime , tb = _run_one (
21
+ fname = Path (fname ),
22
+ pip_install = pip_install ,
23
+ github_issue = create_github_issue ,
24
+ repo = repo ,
25
+ owner = owner ,
26
+ )
27
+ return {"status" : run_status == "ok" , "runtime" : runtime , "traceback" : tb }
28
+
29
+ @dataclass
30
+ class Args :
31
+ nb_name : str = "Chapter00.ipynb"
32
+ project_name : str = "edu"
33
+ entity : str = "examples_repo_test"
34
+ pip_install : bool = True
35
+ create_github_issue : bool = False
36
+ issue_repo : str = None
37
+ issue_owner : str = None
38
+
39
+ if __name__ == "__main__" :
40
+ args = simple_parsing .parse (Args , config_path = "./test_config.yml" )
41
+ # let's set some env variables:
42
+ os .environ ["WANDB_PROJECT" ] = args .project_name
43
+ os .environ ["WANDB_ENTITY" ] = args .entity
44
+ os .environ ["WANDB_NAME" ] = args .nb_name .split ("/" )[- 1 ]
45
+
46
+ weave .init (f"{ args .entity } /{ args .project_name } " )
47
+
48
+ (run_status , runtime , tb ) = run_one (
49
+ fname = args .nb_name ,
50
+ pip_install = args .pip_install ,
51
+ create_github_issue = args .create_github_issue ,
52
+ repo = args .issue_repo ,
53
+ owner = args .issue_owner ,
54
+ )
0 commit comments