@@ -2608,8 +2608,18 @@ async def remove_testsets(testset_ids: List[str]):
26082608 query = select (TestSetDB ).where (TestSetDB .id .in_ (testset_ids ))
26092609 result = await session .execute (query )
26102610 testsets = result .scalars ().all ()
2611- for testset in testsets :
2611+
2612+ for i , testset in enumerate (testsets ):
2613+ log .info (
2614+ f"[TESTSET] DELETE ({ i } ):" ,
2615+ project_id = testset .project_id ,
2616+ testset_id = testset .id ,
2617+ count = len (testset .csvdata ),
2618+ size = len (dumps (testset .csvdata ).encode ("utf-8" )),
2619+ )
2620+
26122621 await session .delete (testset )
2622+
26132623 await session .commit ()
26142624
26152625
@@ -2772,8 +2782,18 @@ async def fetch_testset_by_id(testset_id: str) -> Optional[TestSetDB]:
27722782 async with engine .core_session () as session :
27732783 result = await session .execute (select (TestSetDB ).filter_by (id = testset_uuid ))
27742784 testset = result .scalars ().first ()
2785+
27752786 if not testset :
27762787 raise NoResultFound (f"Testset with id { testset_id } not found" )
2788+
2789+ log .info (
2790+ "[TESTSET] READ:" ,
2791+ project_id = testset .project_id ,
2792+ testset_id = testset .id ,
2793+ count = len (testset .csvdata ),
2794+ size = len (dumps (testset .csvdata ).encode ("utf-8" )),
2795+ )
2796+
27772797 return testset
27782798
27792799
@@ -2791,21 +2811,21 @@ async def create_testset(project_id: str, testset_data: Dict[str, Any]):
27912811 """
27922812
27932813 async with engine .core_session () as session :
2794- testset_db = TestSetDB (** testset_data , project_id = uuid .UUID (project_id ))
2814+ testset = TestSetDB (** testset_data , project_id = uuid .UUID (project_id ))
27952815
27962816 log .info (
2797- "Saving testset :" ,
2798- project_id = testset_db .project_id ,
2799- testset_id = testset_db .id ,
2800- count = len (testset_db .csvdata ),
2801- size = len (dumps (testset_db .csvdata ).encode ("utf-8" )),
2817+ "[TESTSET] CREATE :" ,
2818+ project_id = testset .project_id ,
2819+ testset_id = testset .id ,
2820+ count = len (testset .csvdata ),
2821+ size = len (dumps (testset .csvdata ).encode ("utf-8" )),
28022822 )
28032823
2804- session .add (testset_db )
2824+ session .add (testset )
28052825 await session .commit ()
2806- await session .refresh (testset_db )
2826+ await session .refresh (testset )
28072827
2808- return testset_db
2828+ return testset
28092829
28102830
28112831async def update_testset (testset_id : str , values_to_update : dict ) -> None :
@@ -2824,11 +2844,12 @@ async def update_testset(testset_id: str, values_to_update: dict) -> None:
28242844
28252845 # Validate keys in values_to_update and update attributes
28262846 valid_keys = [key for key in values_to_update .keys () if hasattr (testset , key )]
2847+
28272848 for key in valid_keys :
28282849 setattr (testset , key , values_to_update [key ])
28292850
28302851 log .info (
2831- "Saving testset :" ,
2852+ "[TESTSET] UPDATE :" ,
28322853 project_id = testset .project_id ,
28332854 testset_id = testset .id ,
28342855 count = len (testset .csvdata ),
@@ -2854,6 +2875,16 @@ async def fetch_testsets_by_project_id(project_id: str):
28542875 select (TestSetDB ).filter_by (project_id = uuid .UUID (project_id ))
28552876 )
28562877 testsets = result .scalars ().all ()
2878+
2879+ for i , testset in enumerate (testsets ):
2880+ log .info (
2881+ f"[TESTSET] READ ({ i } ):" ,
2882+ project_id = testset .project_id ,
2883+ testset_id = testset .id ,
2884+ count = len (testset .csvdata ),
2885+ size = len (dumps (testset .csvdata ).encode ("utf-8" )),
2886+ )
2887+
28572888 return testsets
28582889
28592890
0 commit comments