-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
64 lines (58 loc) · 1.99 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Description : This is the head file of the project
Author : Ruidi Qiu ([email protected])
Time : 2023/11/28 11:19:59
LastEdited : 2024/8/29 21:43:15
"""
import loader_saver as ls
from config import Config
import config
import LLM_call as gpt
import autoline as al
import iverilog_call as iv
import getopt
import sys
from config import CFG_CUS_PATH
def main(custom_cfg_path: str = CFG_CUS_PATH):
# my_config = cfg.load_config(custom_cfg_path)
# my_config = ls.add_save_root_to(my_config)
my_config = Config(custom_cfg_path)
ls.add_save_root_to(my_config)
logger = ls.AutoLogger() # initialize the autologger
logger.info("all configurations are loaded, starting the main process...")
match my_config.run.mode:
case "chatgpt":
gpt.run_like_a_chatgpt()
case "iverilog":
iv.run_iverilog()
case "autoline":
al.run_autoline()
# case "dataset_manager":
# pass # TODO
case _:
raise ValueError("Invalid run mode: " + my_config.run.mode)
print("Done!\n\n")
if __name__ == "__main__":
# if no command, run the main function main()
# if -h/--help, print the help message
# if -c/--config + str, first get the custom config path, then run the main function
try:
opts, args = getopt.getopt(sys.argv[1:], "hc:", ["help", "config="])
except getopt.GetoptError as err:
print(err)
sys.exit(2)
if len(opts) == 1:
for opt, arg in opts:
if opt in ("-h", "--help"):
print("Usage: python main.py [-h] [-c <custom_config_path>]")
sys.exit(0)
elif opt in ("-c", "--config"):
config_path = config.get_cfg_path_from_alias(arg)
main(config_path)
sys.exit(0)
elif len(opts) > 1:
print("opts are more than 1; Usage: python main.py [-h] [-c <custom_config_path>]")
sys.exit(2)
else:
main()
sys.exit(0)