Skip to content

Commit

Permalink
add buffer size as abstract collectorstorage method
Browse files Browse the repository at this point in the history
  • Loading branch information
magdalenakuhn17 committed Nov 25, 2023
1 parent 8476fa5 commit 7881940
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/evidently/collector/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def is_ready(self, config: "CollectorConfig", storage: "CollectorStorage") -> bo
print("---")
print("RowsCountTrigger")
print(f"rows_count: {self.rows_count}")
print(f"buffer length:{len(storage._buffers[config.id])}")
if len(storage._buffers[config.id]) > 0:
if len(storage._buffers[config.id]) % self.rows_count == 0:
buffer_size = storage.get_buffer_size(config.id)
print(f"buffer length:{buffer_size}")
if buffer_size > 0:
if buffer_size % self.rows_count == 0:
print("Creating snapshot")
return True
print("Not creating snapshot")
Expand Down
7 changes: 7 additions & 0 deletions src/evidently/collector/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def init_all(self, config):
@abc.abstractmethod
def append(self, id: str, data: Any):
raise NotImplementedError

@abc.abstractmethod
def get_buffer_size(self, id: str):
raise NotImplementedError

@abc.abstractmethod
def get_and_flush(self, id: str):
Expand Down Expand Up @@ -62,6 +66,9 @@ def init(self, id: str):
def append(self, id: str, data: Any):
self._buffers[id].append(data)

def get_buffer_size(self, id: str):
return len(self._buffers[id])

def get_and_flush(self, id: str):
if id not in self._buffers or len(self._buffers[id]) == 0:
return None
Expand Down

0 comments on commit 7881940

Please sign in to comment.