Rename metadata_query to metadata_filter.

This commit is contained in:
Andrew Nguonly
2024-05-14 12:45:16 -07:00
parent 28e5d8f699
commit 6ce9a2860b
4 changed files with 15 additions and 15 deletions
+4 -4
View File
@@ -257,7 +257,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver, AbstractAsyncContextManager):
async def asearch(
self,
metadata_query: CheckpointMetadata,
metadata_filter: CheckpointMetadata,
*,
before: Optional[RunnableConfig] = None,
limit: Optional[int] = None,
@@ -265,12 +265,12 @@ class AsyncSqliteSaver(BaseCheckpointSaver, AbstractAsyncContextManager):
"""Search for checkpoints by metadata asynchronously.
This method retrieves a list of checkpoint tuples from the SQLite
database based on the provided metadata query. The metadata query does
database based on the provided metadata filter. The metadata filter does
not need to contain all keys defined in the CheckpointMetadata class.
The checkpoints are ordered by timestamp in descending order.
Args:
metadata_query (CheckpointMetadata): The metadata query to use for searching the checkpoints.
metadata_filter (CheckpointMetadata): The metadata filter to use for searching the checkpoints.
before (Optional[RunnableConfig]): If provided, only checkpoints before the specified timestamp are returned. Defaults to None.
limit (Optional[int]): The maximum number of checkpoints to return. Defaults to None.
@@ -282,7 +282,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver, AbstractAsyncContextManager):
# construct query
SELECT = "SELECT thread_id, thread_ts, parent_ts, checkpoint, metadata FROM checkpoints "
WHERE = search_where(
metadata_query, [] if before is None else ["thread_ts < ?"]
metadata_filter, [] if before is None else ["thread_ts < ?"]
)
ORDER_BY = "ORDER BY thread_ts DESC "
LIMIT = f"LIMIT {limit}" if limit else ""
+1 -1
View File
@@ -155,7 +155,7 @@ class BaseCheckpointSaver(ABC):
def search(
self,
metadata: CheckpointMetadata,
metadata_filter: CheckpointMetadata,
*,
before: Optional[RunnableConfig] = None,
limit: Optional[int] = None,
+6 -6
View File
@@ -122,7 +122,7 @@ class MemorySaver(BaseCheckpointSaver):
def search(
self,
metadata_query: CheckpointMetadata,
metadata_filter: CheckpointMetadata,
*,
before: Optional[RunnableConfig] = None,
limit: Optional[int] = None,
@@ -130,12 +130,12 @@ class MemorySaver(BaseCheckpointSaver):
"""Search for checkpoints by metadata.
This method retrieves a list of checkpoint tuples from the in-memory
storage based on the provided metadata query. The metadata query does
storage based on the provided metadata filter. The metadata filter does
not need to contain all keys defined in the CheckpointMetadata class.
The checkpoints are ordered by timestamp in descending order.
Args:
metadata_query (CheckpointMetadata): The metadata query to use for searching the checkpoints.
metadata_filter (CheckpointMetadata): The metadata filter to use for searching the checkpoints.
before (Optional[RunnableConfig]): If provided, only checkpoints before the specified timestamp are returned. Defaults to None.
limit (Optional[int]): The maximum number of checkpoints to return. Defaults to None.
@@ -152,7 +152,7 @@ class MemorySaver(BaseCheckpointSaver):
metadata = self.serde.loads(metadata_bytes)
all_keys_match = all(
query_value == metadata[query_key]
for query_key, query_value in metadata_query.items()
for query_key, query_value in metadata_filter.items()
)
# if all query key/value pairs match, yield the checkpoint
@@ -242,7 +242,7 @@ class MemorySaver(BaseCheckpointSaver):
async def asearch(
self,
metadata_query: CheckpointMetadata,
metadata_filter: CheckpointMetadata,
*,
before: Optional[RunnableConfig] = None,
limit: Optional[int] = None,
@@ -254,7 +254,7 @@ class MemorySaver(BaseCheckpointSaver):
"""
loop = asyncio.get_running_loop()
iter = await loop.run_in_executor(
None, partial(self.search, before=before, limit=limit), metadata_query
None, partial(self.search, before=before, limit=limit), metadata_filter
)
while True:
+4 -4
View File
@@ -340,7 +340,7 @@ class SqliteSaver(BaseCheckpointSaver, AbstractContextManager):
def search(
self,
metadata_query: CheckpointMetadata,
metadata_filter: CheckpointMetadata,
*,
before: Optional[RunnableConfig] = None,
limit: Optional[int] = None,
@@ -348,12 +348,12 @@ class SqliteSaver(BaseCheckpointSaver, AbstractContextManager):
"""Search for checkpoints by metadata.
This method retrieves a list of checkpoint tuples from the SQLite
database based on the provided metadata query. The metadata query does
database based on the provided metadata filter. The metadata filter does
not need to contain all keys defined in the CheckpointMetadata class.
The checkpoints are ordered by timestamp in descending order.
Args:
metadata_query (CheckpointMetadata): The metadata query to use for searching the checkpoints.
metadata_filter (CheckpointMetadata): The metadata filter to use for searching the checkpoints.
before (Optional[RunnableConfig]): If provided, only checkpoints before the specified timestamp are returned. Defaults to None.
limit (Optional[int]): The maximum number of checkpoints to return. Defaults to None.
@@ -363,7 +363,7 @@ class SqliteSaver(BaseCheckpointSaver, AbstractContextManager):
# construct query
SELECT = "SELECT thread_id, thread_ts, parent_ts, checkpoint, metadata FROM checkpoints "
WHERE = search_where(
metadata_query, [] if before is None else ["thread_ts < ?"]
metadata_filter, [] if before is None else ["thread_ts < ?"]
)
ORDER_BY = "ORDER BY thread_ts DESC "
LIMIT = f"LIMIT {limit}" if limit else ""