docstrings for checkpoint

This commit is contained in:
Sydney Runkle
2025-05-01 13:29:51 -04:00
parent 5916dc333e
commit cc698b4f2b
3 changed files with 73 additions and 73 deletions
@@ -232,7 +232,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Fetch a checkpoint using the given configuration.
Args:
config (RunnableConfig): Configuration specifying which checkpoint to retrieve.
config: Configuration specifying which checkpoint to retrieve.
Returns:
Optional[Checkpoint]: The requested checkpoint, or None if not found.
@@ -244,7 +244,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Fetch a checkpoint tuple using the given configuration.
Args:
config (RunnableConfig): Configuration specifying which checkpoint to retrieve.
config: Configuration specifying which checkpoint to retrieve.
Returns:
Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found.
@@ -265,10 +265,10 @@ class BaseCheckpointSaver(Generic[V]):
"""List checkpoints that match the given criteria.
Args:
config (Optional[RunnableConfig]): Base configuration for filtering checkpoints.
filter (Optional[Dict[str, Any]]): Additional filtering criteria.
before (Optional[RunnableConfig]): List checkpoints created before this configuration.
limit (Optional[int]): Maximum number of checkpoints to return.
config: Base configuration for filtering checkpoints.
filter: Additional filtering criteria.
before: List checkpoints created before this configuration.
limit: Maximum number of checkpoints to return.
Returns:
Iterator[CheckpointTuple]: Iterator of matching checkpoint tuples.
@@ -288,10 +288,10 @@ class BaseCheckpointSaver(Generic[V]):
"""Store a checkpoint with its configuration and metadata.
Args:
config (RunnableConfig): Configuration for the checkpoint.
checkpoint (Checkpoint): The checkpoint to store.
metadata (CheckpointMetadata): Additional metadata for the checkpoint.
new_versions (ChannelVersions): New channel versions as of this write.
config: Configuration for the checkpoint.
checkpoint: The checkpoint to store.
metadata: Additional metadata for the checkpoint.
new_versions: New channel versions as of this write.
Returns:
RunnableConfig: Updated configuration after storing the checkpoint.
@@ -311,10 +311,10 @@ class BaseCheckpointSaver(Generic[V]):
"""Store intermediate writes linked to a checkpoint.
Args:
config (RunnableConfig): Configuration of the related checkpoint.
writes (List[Tuple[str, Any]]): List of writes to store.
task_id (str): Identifier for the task creating the writes.
task_path (str): Path of the task creating the writes.
config: Configuration of the related checkpoint.
writes: List of writes to store.
task_id: Identifier for the task creating the writes.
task_path: Path of the task creating the writes.
Raises:
NotImplementedError: Implement this method in your custom checkpoint saver.
@@ -328,7 +328,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Delete all checkpoints and writes associated with a specific thread ID.
Args:
thread_id (str): The thread ID whose checkpoints should be deleted.
thread_id: The thread ID whose checkpoints should be deleted.
"""
raise NotImplementedError
@@ -336,7 +336,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Asynchronously fetch a checkpoint using the given configuration.
Args:
config (RunnableConfig): Configuration specifying which checkpoint to retrieve.
config: Configuration specifying which checkpoint to retrieve.
Returns:
Optional[Checkpoint]: The requested checkpoint, or None if not found.
@@ -348,7 +348,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Asynchronously fetch a checkpoint tuple using the given configuration.
Args:
config (RunnableConfig): Configuration specifying which checkpoint to retrieve.
config: Configuration specifying which checkpoint to retrieve.
Returns:
Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found.
@@ -369,10 +369,10 @@ class BaseCheckpointSaver(Generic[V]):
"""Asynchronously list checkpoints that match the given criteria.
Args:
config (Optional[RunnableConfig]): Base configuration for filtering checkpoints.
filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata.
before (Optional[RunnableConfig]): List checkpoints created before this configuration.
limit (Optional[int]): Maximum number of checkpoints to return.
config: Base configuration for filtering checkpoints.
filter: Additional filtering criteria for metadata.
before: List checkpoints created before this configuration.
limit: Maximum number of checkpoints to return.
Returns:
AsyncIterator[CheckpointTuple]: Async iterator of matching checkpoint tuples.
@@ -393,10 +393,10 @@ class BaseCheckpointSaver(Generic[V]):
"""Asynchronously store a checkpoint with its configuration and metadata.
Args:
config (RunnableConfig): Configuration for the checkpoint.
checkpoint (Checkpoint): The checkpoint to store.
metadata (CheckpointMetadata): Additional metadata for the checkpoint.
new_versions (ChannelVersions): New channel versions as of this write.
config: Configuration for the checkpoint.
checkpoint: The checkpoint to store.
metadata: Additional metadata for the checkpoint.
new_versions: New channel versions as of this write.
Returns:
RunnableConfig: Updated configuration after storing the checkpoint.
@@ -416,10 +416,10 @@ class BaseCheckpointSaver(Generic[V]):
"""Asynchronously store intermediate writes linked to a checkpoint.
Args:
config (RunnableConfig): Configuration of the related checkpoint.
writes (List[Tuple[str, Any]]): List of writes to store.
task_id (str): Identifier for the task creating the writes.
task_path (str): Path of the task creating the writes.
config: Configuration of the related checkpoint.
writes: List of writes to store.
task_id: Identifier for the task creating the writes.
task_path: Path of the task creating the writes.
Raises:
NotImplementedError: Implement this method in your custom checkpoint saver.
@@ -433,7 +433,7 @@ class BaseCheckpointSaver(Generic[V]):
"""Delete all checkpoints and writes associated with a specific thread ID.
Args:
thread_id (str): The thread ID whose checkpoints should be deleted.
thread_id: The thread ID whose checkpoints should be deleted.
"""
raise NotImplementedError
@@ -444,8 +444,8 @@ class BaseCheckpointSaver(Generic[V]):
as long as they are monotonically increasing.
Args:
current (Optional[V]): The current version identifier (int, float, or str).
channel (BaseChannel): The channel being versioned.
current: The current version identifier (int, float, or str).
channel: The channel being versioned.
Returns:
V: The next version identifier, which must be increasing.
@@ -41,7 +41,7 @@ class InMemorySaver(
If you are using the LangGraph Platform, no checkpointer needs to be specified. The correct managed checkpointer will be used automatically.
Args:
serde (Optional[SerializerProtocol]): The serializer to use for serializing and deserializing checkpoints. Defaults to None.
serde: The serializer to use for serializing and deserializing checkpoints. Defaults to None.
Examples:
@@ -138,7 +138,7 @@ class InMemorySaver(
for the given thread ID is retrieved.
Args:
config (RunnableConfig): The config to use for retrieving the checkpoint.
config: The config to use for retrieving the checkpoint.
Returns:
Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
@@ -255,10 +255,10 @@ class InMemorySaver(
on the provided criteria.
Args:
config (Optional[RunnableConfig]): Base configuration for filtering checkpoints.
filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata.
before (Optional[RunnableConfig]): List checkpoints created before this configuration.
limit (Optional[int]): Maximum number of checkpoints to return.
config: Base configuration for filtering checkpoints.
filter: Additional filtering criteria for metadata.
before: List checkpoints created before this configuration.
limit: Maximum number of checkpoints to return.
Yields:
Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples.
@@ -380,10 +380,10 @@ class InMemorySaver(
with the provided config.
Args:
config (RunnableConfig): The config to associate with the checkpoint.
checkpoint (Checkpoint): The checkpoint to save.
metadata (CheckpointMetadata): Additional metadata to save with the checkpoint.
new_versions (dict): New versions as of this write
config: The config to associate with the checkpoint.
checkpoint: The checkpoint to save.
metadata: Additional metadata to save with the checkpoint.
new_versions: New versions as of this write
Returns:
RunnableConfig: The updated config containing the saved checkpoint's timestamp.
@@ -427,10 +427,10 @@ class InMemorySaver(
with the provided config.
Args:
config (RunnableConfig): The config to associate with the writes.
writes (list[tuple[str, Any]]): The writes to save.
task_id (str): Identifier for the task creating the writes.
task_path (str): Path of the task creating the writes.
config: The config to associate with the writes.
writes: The writes to save.
task_id: Identifier for the task creating the writes.
task_path: Path of the task creating the writes.
Returns:
RunnableConfig: The updated config containing the saved writes' timestamp.
@@ -456,7 +456,7 @@ class InMemorySaver(
"""Delete all checkpoints and writes associated with a thread ID.
Args:
thread_id (str): The thread ID to delete.
thread_id: The thread ID to delete.
Returns:
None
@@ -477,7 +477,7 @@ class InMemorySaver(
method in a separate thread using asyncio.
Args:
config (RunnableConfig): The config to use for retrieving the checkpoint.
config: The config to use for retrieving the checkpoint.
Returns:
Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found.
@@ -498,7 +498,7 @@ class InMemorySaver(
method in a separate thread using asyncio.
Args:
config (RunnableConfig): The config to use for listing the checkpoints.
config: The config to use for listing the checkpoints.
Yields:
AsyncIterator[CheckpointTuple]: An asynchronous iterator of checkpoint tuples.
@@ -516,10 +516,10 @@ class InMemorySaver(
"""Asynchronous version of put.
Args:
config (RunnableConfig): The config to associate with the checkpoint.
checkpoint (Checkpoint): The checkpoint to save.
metadata (CheckpointMetadata): Additional metadata to save with the checkpoint.
new_versions (dict): New versions as of this write
config: The config to associate with the checkpoint.
checkpoint: The checkpoint to save.
metadata: Additional metadata to save with the checkpoint.
new_versions: New versions as of this write
Returns:
RunnableConfig: The updated config containing the saved checkpoint's timestamp.
@@ -539,10 +539,10 @@ class InMemorySaver(
method in a separate thread using asyncio.
Args:
config (RunnableConfig): The config to associate with the writes.
writes (List[Tuple[str, Any]]): The writes to save, each as a (channel, value) pair.
task_id (str): Identifier for the task creating the writes.
task_path (str): Path of the task creating the writes.
config: The config to associate with the writes.
writes: The writes to save, each as a (channel, value) pair.
task_id: Identifier for the task creating the writes.
task_path: Path of the task creating the writes.
Returns:
None
@@ -553,7 +553,7 @@ class InMemorySaver(
"""Delete all checkpoints and writes associated with a thread ID.
Args:
thread_id (str): The thread ID to delete.
thread_id: The thread ID to delete.
Returns:
None
@@ -52,13 +52,13 @@ class Item:
"""Represents a stored item with metadata.
Args:
value (dict[str, Any]): The stored data as a dictionary. Keys are filterable.
key (str): Unique identifier within the namespace.
namespace (tuple[str, ...]): Hierarchical path defining the collection in which this document resides.
value: The stored data as a dictionary. Keys are filterable.
key: Unique identifier within the namespace.
namespace: Hierarchical path defining the collection in which this document resides.
Represented as a tuple of strings, allowing for nested categorization.
For example: ("documents", 'user123')
created_at (datetime): Timestamp of item creation.
updated_at (datetime): Timestamp of last update.
created_at: Timestamp of item creation.
updated_at: Timestamp of last update.
"""
__slots__ = ("value", "key", "namespace", "created_at", "updated_at")
@@ -913,12 +913,12 @@ class BaseStore(ABC):
find specific collections, or navigate the namespace hierarchy.
Args:
prefix (Optional[Tuple[str, ...]]): Filter namespaces that start with this path.
suffix (Optional[Tuple[str, ...]]): Filter namespaces that end with this path.
max_depth (Optional[int]): Return namespaces up to this depth in the hierarchy.
prefix: Filter namespaces that start with this path.
suffix: Filter namespaces that end with this path.
max_depth: Return namespaces up to this depth in the hierarchy.
Namespaces deeper than this level will be truncated.
limit (int): Maximum number of namespaces to return (default 100).
offset (int): Number of namespaces to skip for pagination (default 0).
limit: Maximum number of namespaces to return (default 100).
offset: Number of namespaces to skip for pagination (default 0).
Returns:
List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
@@ -1162,12 +1162,12 @@ class BaseStore(ABC):
find specific collections, or navigate the namespace hierarchy.
Args:
prefix (Optional[Tuple[str, ...]]): Filter namespaces that start with this path.
suffix (Optional[Tuple[str, ...]]): Filter namespaces that end with this path.
max_depth (Optional[int]): Return namespaces up to this depth in the hierarchy.
prefix: Filter namespaces that start with this path.
suffix: Filter namespaces that end with this path.
max_depth: Return namespaces up to this depth in the hierarchy.
Namespaces deeper than this level will be truncated to this depth.
limit (int): Maximum number of namespaces to return (default 100).
offset (int): Number of namespaces to skip for pagination (default 0).
limit: Maximum number of namespaces to return (default 100).
offset: Number of namespaces to skip for pagination (default 0).
Returns:
List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.