File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1+ import param
2+
3+
4+ class Cache (param .Parameterized ):
5+ pass
6+
7+
8+ class MemoryCache (param .Parameterized ):
9+
10+ _cache = param .Dict (default = {})
11+
12+ def __getitem__ (self , item ):
13+ return self ._cache .get (item )
14+
15+ def __setitem__ (self , key , value ):
16+ self ._cache [key ] = value
Original file line number Diff line number Diff line change @@ -23,7 +23,13 @@ def get(self):
2323
2424class TableSource (Source ):
2525
26- tables = param .Dict ({})
26+ tables = param .Dict (
27+ default = {},
28+ doc = "Dictionary of tables (pd.DataFrames)" )
29+
30+ hashes = param .Dict (
31+ default = {},
32+ doc = "Dictionary of table hashes" )
2733
2834 _type = 'table'
2935
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class Transform(param.Parameterized):
2121
2222 redrawn = param .Event (doc = "event gets triggered when widgets are changed and the controller needs to redraw them" )
2323
24+ cache = param .ClassSelector (class_ = Cache )
25+
2426 def __init__ (self , ** params ):
2527 super ().__init__ (** params )
2628
@@ -53,6 +55,12 @@ def get(self):
5355 df = self .source .get_table (self .table ) # returns None on KeyError #todo change to source.get_table
5456 return df
5557
58+ @property
59+ def hash (self ):
60+ # or sources can have multiple hashes?
61+ # / objects can have multiple hashes?
62+ return tuple ([self ._type , self .table , self .source .hashes [self .table ]])
63+
5664 @param .depends ('table' , watch = True )
5765 def _table_updated (self ):
5866 self .updated = True
You can’t perform that action at this time.
0 commit comments