forked from amyotjl/GraphToPDDL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoPDDL.py
More file actions
80 lines (67 loc) · 2.42 KB
/
toPDDL.py
File metadata and controls
80 lines (67 loc) · 2.42 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from src.script import run_to_pddl
import argparse as ap
import traceback
import logging
if __name__ == "__main__":
parser = ap.ArgumentParser()
parser.add_argument(
"ag", type=str, help="Path to the AG file. It must be a DOT file."
)
parser.add_argument(
"--ro",
type=str,
help="Path to the revision operator file. It must be a JSON file.",
)
parser.add_argument(
"--p",
type=str,
help="Path to the patient values file. It must be a JSON file.",
)
parser.add_argument(
"--p-name",
type=str,
default="mitplan-problem",
help="Problem name. It is also the name of the output PDDL file (e.g. --p-name problem).",
)
parser.add_argument(
"--d-name",
type=str,
default="mitplan-domain",
help="Domain name.",
)
parser.add_argument(
"--log",
type=str,
default="INFO",
help="Logging level"
)
# parser.add_argument(
# "--no-ro",
# action="store_true",
# default=False,
# help="If true, does not apply any revision operators. It will output the original graph with the corresponding PDDL.",
# )
parser.add_argument(
"--dir",
type=str,
default="",
help="Path to the directory where to create the problem and graph view files. Default value is the current directory",
)
args = parser.parse_args()
try:
if not args.ag:
raise Exception(
"An AG (extended or not) file is needed. Please use the flag --ag or --agx followed by the path to the file.\nUse the flag -h for more information"
)
if args.ag and args.ag[-3:].lower() != "dot":
raise Exception("The AG file (--ag) must be a DOT file.")
if args.ro != None and args.ro[-4:].lower() != "json":
raise Exception("The Revision operators file (--ro) must be a JSON file.")
if args.p != None and args.p[-4:].lower() != "json":
raise Exception("The Revision operators file (--ro) must be a JSON file.")
log_level = getattr(logging, args.log.upper(), logging.INFO)
logging.basicConfig(level=log_level, format='%(levelname)s %(asctime)s: %(message)s')
run_to_pddl(args.ag, args.ro, args.p, args.p_name, args.d_name, args.dir)
except Exception as e:
print(e)
traceback.print_exc()