@@ -37,6 +37,7 @@ def generate_chart():
3737 config_path = sorted (configs )[0 ]
3838 pc_specs = {}
3939 data_specs = {}
40+ report_file = ""
4041
4142 if os .path .exists (config_path ):
4243 try :
@@ -54,10 +55,11 @@ def generate_chart():
5455 except Exception as e :
5556 print (f"Error loading config file: { config_path } : { e } " )
5657
57- # 2. Read report files — keyed by (dataset, phase)
5858 KNOWN_PHASES = ["train" , "match" ]
5959 series = {}
60- for file_path in sorted (glob .glob ("*_report.csv" )):
60+ report_dir = os .path .dirname (report_file ) if report_file else ""
61+ csv_pattern = os .path .join (report_dir , "*_report.csv" ) if report_dir else "*_report.csv"
62+ for file_path in sorted (glob .glob (csv_pattern )):
6163 basename = os .path .basename (file_path ).replace ("_report.csv" , "" )
6264 phase = next ((p for p in KNOWN_PHASES if basename == p or basename .endswith (f"_{ p } " )), None )
6365 if phase is None :
@@ -134,6 +136,9 @@ def concat_phase(phase_name):
134136 ax .tick_params (axis = 'both' , colors = '#8e8f9e' , labelsize = 8.5 )
135137 ax .grid (True , color = '#222332' , linestyle = ':' , linewidth = 0.8 )
136138
139+ max_duration = max (df ["duration" ].max () for df in series .values ())
140+ ax .set_ylim (0 , max_duration * 1.3 )
141+
137142
138143 for spine in ['top' , 'right' ]:
139144 ax .spines [spine ].set_visible (False )
@@ -150,11 +155,9 @@ def concat_phase(phase_name):
150155 today_str = datetime .now ().strftime ("%Y-%m-%d" )
151156 fig .text (0.94 , 0.953 , f"Generated: { today_str } " , color = '#8e8f9e' , fontsize = 8.5 , ha = 'right' )
152157
153- # 7. Render Footer Specs Section
154158 ax_footer = fig .add_subplot (gs [1 ])
155159 ax_footer .axis ('off' )
156160
157- # PC Specs
158161 ax_footer .text (0.02 , 0.85 , "PC Specs" , color = '#ffffff' , fontsize = 10.5 , fontweight = 'bold' )
159162 pc_keys = ["OS" , "CPU" , "RAM" , "Storage" , "Spark" , "Java" ]
160163 y_pos = 0.65
@@ -176,7 +179,6 @@ def concat_phase(phase_name):
176179 ax_footer .text (0.11 , y_pos , val , color = '#cbd5e1' , fontsize = 8.5 )
177180 y_pos -= 0.12
178181
179- # Data Specs
180182 ax_footer .text (0.35 , 0.85 , "Data Specs" , color = '#ffffff' , fontsize = 10.5 , fontweight = 'bold' )
181183 data_keys = ["Dataset" , "Records" , "Fields" , "Pairs" , "Blocking" , "Model" ]
182184 y_pos = 0.65
@@ -189,7 +191,6 @@ def concat_phase(phase_name):
189191 ax_footer .text (0.44 , y_pos , val , color = '#cbd5e1' , fontsize = 8.5 )
190192 y_pos -= 0.12
191193
192- # Run Summary
193194 ax_footer .text (0.76 , 0.85 , "Run Summary" , color = '#ffffff' , fontsize = 10.5 , fontweight = 'bold' )
194195 summary_items = [
195196 ("Total Runs" , f"{ total_runs } " ),
@@ -205,10 +206,15 @@ def concat_phase(phase_name):
205206 ax_footer .text (0.87 , y_pos , val , color = '#cbd5e1' , fontsize = 8.5 )
206207 y_pos -= 0.12
207208
208- # Save output image
209- plt .savefig ("performance_chart.png" , dpi = 150 , bbox_inches = 'tight' , facecolor = fig .get_facecolor ())
209+ chart_dir = os .path .dirname (report_file ) if report_file else ""
210+ if chart_dir :
211+ os .makedirs (chart_dir , exist_ok = True )
212+ chart_path = os .path .join (chart_dir , "performance_chart.png" )
213+ else :
214+ chart_path = "performance_chart.png"
215+ plt .savefig (chart_path , dpi = 150 , bbox_inches = 'tight' , facecolor = fig .get_facecolor ())
210216 plt .close ()
211- print ("Performance chart successfully updated at performance_chart.png !" )
217+ print (f "Performance chart successfully updated at { chart_path } !" )
212218
213219if __name__ == "__main__" :
214220 generate_chart ()
0 commit comments