1-
2-
31import copy
42from datetime import datetime
53
@@ -13,15 +11,16 @@ def __init__(
1311 componentName : str ,
1412 ):
1513 self .component_name = componentName
16- self .store = Store (clientUtils .get_db_uri ())
1714
1815 def get_runs_by_time (
1916 self ,
2017 start_time : datetime = datetime .min ,
2118 end_time : datetime = datetime .max ,
2219 ):
23- history_runs = self .store .get_history (
24- self .component_name , None , start_time , end_time )
20+ store = Store (clientUtils .get_db_uri ())
21+ history_runs = store .get_history (
22+ self .component_name , None , start_time , end_time
23+ )
2524 history_runs = clientUtils .convertToClient (history_runs )
2625 return history_runs
2726
@@ -30,16 +29,24 @@ def get_runs_by_index(
3029 front_idx : int ,
3130 last_idx : int ,
3231 ):
33- history_runs = self .store .get_component_runs_by_index (
34- self .component_name , front_idx , last_idx )
32+ store = Store (clientUtils .get_db_uri ())
33+ history_runs = store .get_component_runs_by_index (
34+ self .component_name , front_idx , last_idx
35+ )
3536 history_runs = clientUtils .convertToClient (history_runs )
3637 return history_runs
3738
3839 def __getitem__ (self , index ):
39- history_run = self .store .get_component_runs_by_index (
40- self .component_name , index , index + 1 )
40+ store = Store (clientUtils .get_db_uri ())
41+ history_run = store .get_component_runs_by_index (
42+ self .component_name , index , index + 1
43+ )
4144 history_run = clientUtils .convertToClient (history_run )
4245 return history_run
4346
4447 def __len__ (self ):
45- return self .store .get_component_runs_count (self .component_name )
48+ store = Store (clientUtils .get_db_uri ())
49+ return store .get_component_runs_count (self .component_name )
50+
51+ def __repr__ (self ) -> str :
52+ return f"History({ self .component_name } )"
0 commit comments