Skip to content

Commit c976caf

Browse files
Refactored the codebase with dependency injection pattern
* Refactored the codebase with new architecture pattern * Adjusted inference engine test to new pattern * Adjusted inference engine test to new pattern and fixed bugs * Adjusted embedding metadata test to new pattern and fixed bugs * Adjusted embedding engine test to new pattern * Adjusted core test to new pattern * Adjusted benchmark to new pattern logic * Fixed relative paths --------- Co-authored-by: Luis Gaspar Schroeder <luis.gasparschroeder@gmail.com>
1 parent fd7c572 commit c976caf

61 files changed

Lines changed: 749 additions & 977 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/_plotter_individual.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def plot_error_rate_relative(benchmark: Benchmark, FONT_SIZE=20):
2121
plt.title(f'Relative Error Rate vs. Number of Samples (Relative To Reused Answers)')
2222
add_description(benchmark, plt)
2323

24-
filename = benchmark.output_folder_path + f'error_rate_relative_{benchmark.timestamp}.pdf'
24+
filename = benchmark.output_folder_path + f'/error_rate_relative_{benchmark.timestamp}.pdf'
2525
plt.savefig(filename, format='pdf')
2626
plt.close()
2727

@@ -40,7 +40,7 @@ def plot_error_rate_absolute(benchmark: Benchmark, FONT_SIZE=20):
4040
plt.title(f'Absolute Error Rate vs. Number of Samples')
4141
add_description(benchmark, plt)
4242

43-
filename = filename = benchmark.output_folder_path + f'error_rate_absolute_{benchmark.timestamp}.pdf'
43+
filename = filename = benchmark.output_folder_path + f'/error_rate_absolute_{benchmark.timestamp}.pdf'
4444
plt.savefig(filename, format='pdf')
4545
plt.close()
4646

@@ -59,7 +59,7 @@ def plot_relative_error_rate_step_size_(benchmark: Benchmark, FONT_SIZE=20):
5959
plt.title(f'Relative Error Rate per Step Size vs. Number of Samples')
6060
add_description(benchmark, plt)
6161

62-
filename = filename = benchmark.output_folder_path + f'relative_error_rate_step_size_{benchmark.timestamp}.pdf'
62+
filename = filename = benchmark.output_folder_path + f'/relative_error_rate_step_size_{benchmark.timestamp}.pdf'
6363
plt.savefig(filename, format='pdf')
6464
plt.close()
6565

@@ -82,7 +82,7 @@ def plot_reuse_rate(benchmark: Benchmark, FONT_SIZE=20):
8282
plt.title(f'Cache Hit Rate vs. Number of Samples')
8383
add_description(benchmark, plt)
8484

85-
filename = filename = benchmark.output_folder_path + f'reuse_rate_{benchmark.timestamp}.pdf'
85+
filename = filename = benchmark.output_folder_path + f'/reuse_rate_{benchmark.timestamp}.pdf'
8686
plt.savefig(filename, format='pdf')
8787
plt.close()
8888

@@ -101,7 +101,7 @@ def plot_relative_reuse_rate(benchmark: Benchmark, FONT_SIZE=20):
101101
plt.title(f'Relative Cache Hit Rate vs. Number of Samples')
102102
add_description(benchmark, plt)
103103

104-
filename = filename = benchmark.output_folder_path + f'relative_reuse_rate_step_size_{benchmark.timestamp}.pdf'
104+
filename = filename = benchmark.output_folder_path + f'/relative_reuse_rate_step_size_{benchmark.timestamp}.pdf'
105105
plt.savefig(filename, format='pdf')
106106
plt.close()
107107

@@ -116,7 +116,7 @@ def plot_duration_step_size(benchmark: Benchmark, FONT_SIZE=20):
116116
plt.legend()
117117
plt.grid(True)
118118
add_description(benchmark, plt)
119-
filename = filename = benchmark.output_folder_path + f'relative_duration_step_size_{benchmark.timestamp}.pdf'
119+
filename = filename = benchmark.output_folder_path + f'/relative_duration_step_size_{benchmark.timestamp}.pdf'
120120
plt.savefig(filename, format='pdf')
121121
plt.close()
122122

@@ -134,7 +134,7 @@ def plot_duration_trend(benchmark: Benchmark, FONT_SIZE=20):
134134
plt.title('Total Inference Time vs. Number of Samples')
135135
plt.legend()
136136
add_description(benchmark, plt)
137-
filename = filename = benchmark.output_folder_path + f'duration_trend_{benchmark.timestamp}.pdf'
137+
filename = filename = benchmark.output_folder_path + f'/duration_trend_{benchmark.timestamp}.pdf'
138138
plt.savefig(filename, bbox_inches='tight')
139139
plt.close()
140140

@@ -147,7 +147,7 @@ def plot_precision(benchmark: Benchmark, FONT_SIZE=20):
147147
plt.title('Precision vs. Number of Samples')
148148
plt.ylim(0, 1) # Set fixed y-axis range from 0 to 1
149149
add_description(benchmark, plt)
150-
filename = filename = benchmark.output_folder_path + f'precision_{benchmark.timestamp}.pdf'
150+
filename = filename = benchmark.output_folder_path + f'/precision_{benchmark.timestamp}.pdf'
151151
plt.savefig(filename, bbox_inches='tight')
152152
plt.close()
153153

@@ -160,7 +160,7 @@ def plot_recall(benchmark: Benchmark, FONT_SIZE=20):
160160
plt.title('Recall vs. Number of Samples')
161161
plt.ylim(0, 1) # Set fixed y-axis range from 0 to 1
162162
add_description(benchmark, plt)
163-
filename = filename = benchmark.output_folder_path + f'recall_{benchmark.timestamp}.pdf'
163+
filename = filename = benchmark.output_folder_path + f'/recall_{benchmark.timestamp}.pdf'
164164
plt.savefig(filename, bbox_inches='tight')
165165
plt.close()
166166

@@ -173,7 +173,7 @@ def plot_accuracy(benchmark: Benchmark, FONT_SIZE=20):
173173
plt.title('Accuracy vs. Number of Samples')
174174
plt.ylim(0, 1) # Set fixed y-axis range from 0 to 1
175175
add_description(benchmark, plt)
176-
filename = filename = benchmark.output_folder_path + f'accuracy_{benchmark.timestamp}.pdf'
176+
filename = filename = benchmark.output_folder_path + f'/accuracy_{benchmark.timestamp}.pdf'
177177
plt.savefig(filename, bbox_inches='tight')
178178
plt.close()
179179

@@ -186,7 +186,7 @@ def plot_cache_size(benchmark: Benchmark, FONT_SIZE=20):
186186
plt.ylabel('Cache Size (MB)')
187187
plt.title('Cache Size Growth vs. Number of Samples')
188188
add_description(benchmark, plt)
189-
filename = benchmark.output_folder_path + f'cache_size_{benchmark.timestamp}.pdf'
189+
filename = benchmark.output_folder_path + f'/cache_size_{benchmark.timestamp}.pdf'
190190
plt.savefig(filename, bbox_inches='tight')
191191
plt.close()
192192

@@ -294,7 +294,7 @@ def plot_cache_hit_latency_vs_size(benchmark: Benchmark, FONT_SIZE=20):
294294

295295
#add_description(benchmark, plt)
296296

297-
filename = benchmark.output_folder_path + f'cache_hit_latency_vs_size_{benchmark.timestamp}.pdf'
297+
filename = benchmark.output_folder_path + f'/cache_hit_latency_vs_size_{benchmark.timestamp}.pdf'
298298
plt.savefig(filename, format='pdf', bbox_inches='tight')
299299
plt.close()
300300

@@ -345,8 +345,8 @@ def plot_combined_thresholds_and_posteriors(benchmark: Benchmark):
345345

346346
plt.tight_layout()
347347

348-
output_folder_path = benchmark.output_folder_path + f'thresholds_and_posteriors/'
349-
filename = benchmark.output_folder_path + f'thresholds_and_posteriors/combined_embedding_{idx}_{benchmark.timestamp}.pdf'
348+
output_folder_path = benchmark.output_folder_path + f'/thresholds_and_posteriors/'
349+
filename = benchmark.output_folder_path + f'/thresholds_and_posteriors/combined_embedding_{idx}_{benchmark.timestamp}.pdf'
350350
if output_folder_path and not os.path.exists(output_folder_path):
351351
os.makedirs(output_folder_path)
352352
plt.savefig(filename, format='pdf', bbox_inches='tight')

0 commit comments

Comments
 (0)