Update synoptic_chart_generator.py
Browse files- synoptic_chart_generator.py +89 -0
synoptic_chart_generator.py
CHANGED
@@ -7,6 +7,95 @@ from graph_generator_utils import add_nodes_and_edges
|
|
7 |
def generate_synoptic_chart(json_input: str) -> str:
|
8 |
"""
|
9 |
Generates a synoptic chart (horizontal flowchart) from JSON input.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
"""
|
11 |
try:
|
12 |
if not json_input.strip():
|
|
|
7 |
def generate_synoptic_chart(json_input: str) -> str:
|
8 |
"""
|
9 |
Generates a synoptic chart (horizontal flowchart) from JSON input.
|
10 |
+
|
11 |
+
Args:
|
12 |
+
json_input (str): A JSON string describing the synoptic chart structure.
|
13 |
+
It must follow the Expected JSON Format Example below.
|
14 |
+
|
15 |
+
Expected JSON Format Example:
|
16 |
+
{
|
17 |
+
"central_node": "AI Project Lifecycle",
|
18 |
+
"nodes": [
|
19 |
+
{
|
20 |
+
"id": "phase1",
|
21 |
+
"label": "I. Problem Definition & Data Acquisition",
|
22 |
+
"relationship": "Starts with",
|
23 |
+
"subnodes": [
|
24 |
+
{
|
25 |
+
"id": "sub1_1",
|
26 |
+
"label": "1. Problem Formulation",
|
27 |
+
"relationship": "Involves",
|
28 |
+
"subnodes": [
|
29 |
+
{"id": "sub1_1_1", "label": "1.1. Identify Business Need", "relationship": "e.g."},
|
30 |
+
{"id": "sub1_1_2", "label": "1.2. Define KPIs", "relationship": "e.g."}
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"id": "sub1_2",
|
35 |
+
"label": "2. Data Collection",
|
36 |
+
"relationship": "Followed by",
|
37 |
+
"subnodes": [
|
38 |
+
{"id": "sub1_2_1", "label": "2.1. Source Data", "relationship": "from"},
|
39 |
+
{"id": "sub1_2_2", "label": "2.2. Data Cleaning", "relationship": "includes"}
|
40 |
+
]
|
41 |
+
}
|
42 |
+
]
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"id": "phase2",
|
46 |
+
"label": "II. Model Development",
|
47 |
+
"relationship": "Proceeds to",
|
48 |
+
"subnodes": [
|
49 |
+
{
|
50 |
+
"id": "sub2_1",
|
51 |
+
"label": "1. Feature Engineering",
|
52 |
+
"relationship": "Comprises",
|
53 |
+
"subnodes": [
|
54 |
+
{"id": "sub2_1_1", "label": "1.1. Feature Selection", "relationship": "e.g."},
|
55 |
+
{"id": "sub2_1_2", "label": "1.2. Feature Transformation", "relationship": "e.g."}
|
56 |
+
]
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"id": "sub2_2",
|
60 |
+
"label": "2. Model Training",
|
61 |
+
"relationship": "Involves",
|
62 |
+
"subnodes": [
|
63 |
+
{"id": "sub2_2_1", "label": "2.1. Algorithm Selection", "relationship": "uses"},
|
64 |
+
{"id": "sub2_2_2", "label": "2.2. Hyperparameter Tuning", "relationship": "optimizes"}
|
65 |
+
]
|
66 |
+
}
|
67 |
+
]
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"id": "phase3",
|
71 |
+
"label": "III. Evaluation & Deployment",
|
72 |
+
"relationship": "Culminates in",
|
73 |
+
"subnodes": [
|
74 |
+
{
|
75 |
+
"id": "sub3_1",
|
76 |
+
"label": "1. Model Evaluation",
|
77 |
+
"relationship": "Includes",
|
78 |
+
"subnodes": [
|
79 |
+
{"id": "sub3_1_1", "label": "1.1. Performance Metrics", "relationship": "measures"},
|
80 |
+
{"id": "sub3_1_2", "label": "1.2. Bias & Fairness Audits", "relationship": "ensures"}
|
81 |
+
]
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"id": "sub3_2",
|
85 |
+
"label": "2. Deployment & Monitoring",
|
86 |
+
"relationship": "Requires",
|
87 |
+
"subnodes": [
|
88 |
+
{"id": "sub3_2_1", "label": "2.1. API/Integration Development", "relationship": "for"},
|
89 |
+
{"id": "sub3_2_2", "label": "2.2. Continuous Monitoring", "relationship": "ensures"}
|
90 |
+
]
|
91 |
+
}
|
92 |
+
]
|
93 |
+
}
|
94 |
+
]
|
95 |
+
}
|
96 |
+
|
97 |
+
Returns:
|
98 |
+
str: The filepath to the generated PNG image file.
|
99 |
"""
|
100 |
try:
|
101 |
if not json_input.strip():
|