99SUMMARY_LENGTH = 100
1010LABELS_SUMMARY_LENGTH = 15
1111
12+
1213def display_found_details (data : list ):
1314 from test2text .services .utils import unpack_float32
1415 from test2text .services .visualisation .visualize_vectors import (
@@ -17,39 +18,37 @@ def display_found_details(data: list):
1718 minifold_vectors_3d ,
1819 plot_2_sets_in_one_3d ,
1920 )
21+
2022 def write_annotations (current_annotations : set [tuple ]):
2123 st .write ("id," , "Summary," , "Distance" )
2224 for anno_id , anno_summary , _ , distance in current_annotations :
2325 st .write (anno_id , anno_summary , round_distance (distance ))
2426
25-
2627 for (
27- req_id ,
28- req_external_id ,
29- req_summary ,
30- req_embedding ,
28+ req_id ,
29+ req_external_id ,
30+ req_summary ,
31+ req_embedding ,
3132 ), group in groupby (data , lambda x : x [0 :4 ]):
3233 st .divider ()
3334 with st .container ():
3435 st .subheader (f" Inspect Requirement { req_external_id } " )
3536 st .write (req_summary )
3637 current_test_cases = dict ()
3738 for (
38- _ ,
39- _ ,
40- _ ,
41- _ ,
42- anno_id ,
43- anno_summary ,
44- anno_embedding ,
45- distance ,
46- case_id ,
47- test_script ,
48- test_case ,
39+ _ ,
40+ _ ,
41+ _ ,
42+ _ ,
43+ anno_id ,
44+ anno_summary ,
45+ anno_embedding ,
46+ distance ,
47+ case_id ,
48+ test_script ,
49+ test_case ,
4950 ) in group :
50- current_annotation = current_test_cases .get (
51- test_case , set ()
52- )
51+ current_annotation = current_test_cases .get (test_case , set ())
5352 current_test_cases .update ({test_case : current_annotation })
5453 current_test_cases [test_case ].add (
5554 (anno_id , anno_summary , anno_embedding , distance )
@@ -82,9 +81,7 @@ def write_annotations(current_annotations: set[tuple]):
8281 with anno :
8382 with st .container (border = True ):
8483 st .write ("Annotations" )
85- st .info (
86- "List of Annotations for chosen Test case"
87- )
84+ st .info ("List of Annotations for chosen Test case" )
8885 write_annotations (
8986 current_annotations = current_test_cases [
9087 st .session_state ["radio_choice" ]
@@ -114,9 +111,7 @@ def write_annotations(current_annotations: set[tuple]):
114111 annotation_vectors = np .array (anno_embeddings )
115112 if select == "2D" :
116113 plot_2_sets_in_one_2d (
117- minifold_vectors_2d (
118- requirement_vectors
119- ),
114+ minifold_vectors_2d (requirement_vectors ),
120115 minifold_vectors_2d (annotation_vectors ),
121116 "Requirement" ,
122117 "Annotations" ,
@@ -143,7 +138,7 @@ def write_annotations(current_annotations: set[tuple]):
143138def make_a_report ():
144139 from test2text .services .db import get_db_client
145140
146- with ( get_db_client () as db ) :
141+ with get_db_client () as db :
147142 st .header ("Test2Text Report" )
148143
149144 with st .container (border = True ):
@@ -166,10 +161,12 @@ def make_a_report():
166161
167162 with st .container (border = True ):
168163 st .session_state .update ({"req_form_submitting" : True })
169- data = requirements .fetch_filtered_requirements (db ,
170- external_id = filter_id ,
171- text_content = filter_summary ,
172- smart_search_query = filter_embedding )
164+ data = requirements .fetch_filtered_requirements (
165+ db ,
166+ external_id = filter_id ,
167+ text_content = filter_summary ,
168+ smart_search_query = filter_embedding ,
169+ )
173170
174171 requirements_dict = {
175172 req_id : f"{ req_external_id } { summary [:SUMMARY_LENGTH ]} ..."
@@ -208,7 +205,9 @@ def make_a_report():
208205 )
209206 st .info ("Limit of selected test cases" )
210207
211- rows = test_cases .fetch_test_cases_by_requirement (db , selected_requirement , filter_radius , filter_limit )
208+ rows = test_cases .fetch_test_cases_by_requirement (
209+ db , selected_requirement , filter_radius , filter_limit
210+ )
212211
213212 if not rows :
214213 st .error (
@@ -219,6 +218,5 @@ def make_a_report():
219218 display_found_details (rows )
220219
221220
222-
223221if __name__ == "__main__" :
224222 make_a_report ()
0 commit comments