3535CHECKPOINT_BLOB_PREFIX = "checkpoint_blob"
3636CHECKPOINT_WRITE_PREFIX = "checkpoint_write"
3737
38- SCHEMAS = [
39- {
40- "index" : {
41- "name" : "checkpoints" ,
42- "prefix" : CHECKPOINT_PREFIX + REDIS_KEY_SEPARATOR ,
43- "storage_type" : "json" ,
44- },
45- "fields" : [
46- {"name" : "thread_id" , "type" : "tag" },
47- {"name" : "checkpoint_ns" , "type" : "tag" },
48- {"name" : "checkpoint_id" , "type" : "tag" },
49- {"name" : "parent_checkpoint_id" , "type" : "tag" },
50- {"name" : "checkpoint_ts" , "type" : "numeric" },
51- {"name" : "source" , "type" : "tag" },
52- {"name" : "step" , "type" : "numeric" },
53- {"name" : "has_writes" , "type" : "tag" },
54- ],
55- },
56- {
57- "index" : {
58- "name" : "checkpoints_blobs" ,
59- "prefix" : CHECKPOINT_BLOB_PREFIX + REDIS_KEY_SEPARATOR ,
60- "storage_type" : "json" ,
61- },
62- "fields" : [
63- {"name" : "thread_id" , "type" : "tag" },
64- {"name" : "checkpoint_ns" , "type" : "tag" },
65- {"name" : "checkpoint_id" , "type" : "tag" },
66- {"name" : "channel" , "type" : "tag" },
67- {"name" : "version" , "type" : "tag" },
68- {"name" : "type" , "type" : "tag" },
69- ],
70- },
71- {
72- "index" : {
73- "name" : "checkpoint_writes" ,
74- "prefix" : CHECKPOINT_WRITE_PREFIX + REDIS_KEY_SEPARATOR ,
75- "storage_type" : "json" ,
76- },
77- "fields" : [
78- {"name" : "thread_id" , "type" : "tag" },
79- {"name" : "checkpoint_ns" , "type" : "tag" },
80- {"name" : "checkpoint_id" , "type" : "tag" },
81- {"name" : "task_id" , "type" : "tag" },
82- {"name" : "idx" , "type" : "numeric" },
83- {"name" : "channel" , "type" : "tag" },
84- {"name" : "type" , "type" : "tag" },
85- ],
86- },
87- ]
88-
8938
9039class BaseRedisSaver (BaseCheckpointSaver [str ], Generic [RedisClientType , IndexType ]):
9140 """Base Redis implementation for checkpoint saving.
@@ -96,7 +45,6 @@ class BaseRedisSaver(BaseCheckpointSaver[str], Generic[RedisClientType, IndexTyp
9645 _redis : RedisClientType
9746 _owns_its_client : bool = False
9847 _key_registry : Optional [Any ] = None
99- SCHEMAS = SCHEMAS
10048
10149 checkpoints_index : IndexType
10250 checkpoint_blobs_index : IndexType
@@ -138,58 +86,6 @@ def __init__(
13886 self ._checkpoint_blob_prefix = checkpoint_blob_prefix
13987 self ._checkpoint_write_prefix = checkpoint_write_prefix
14088
141- # Create instance-level schemas with custom prefixes
142- self .SCHEMAS = [
143- {
144- "index" : {
145- "name" : self ._checkpoint_prefix ,
146- "prefix" : self ._checkpoint_prefix + REDIS_KEY_SEPARATOR ,
147- "storage_type" : "json" ,
148- },
149- "fields" : [
150- {"name" : "thread_id" , "type" : "tag" },
151- {"name" : "checkpoint_ns" , "type" : "tag" },
152- {"name" : "checkpoint_id" , "type" : "tag" },
153- {"name" : "parent_checkpoint_id" , "type" : "tag" },
154- {"name" : "checkpoint_ts" , "type" : "numeric" },
155- {"name" : "source" , "type" : "tag" },
156- {"name" : "step" , "type" : "numeric" },
157- {"name" : "has_writes" , "type" : "tag" },
158- ],
159- },
160- {
161- "index" : {
162- "name" : self ._checkpoint_blob_prefix ,
163- "prefix" : self ._checkpoint_blob_prefix + REDIS_KEY_SEPARATOR ,
164- "storage_type" : "json" ,
165- },
166- "fields" : [
167- {"name" : "thread_id" , "type" : "tag" },
168- {"name" : "checkpoint_ns" , "type" : "tag" },
169- {"name" : "checkpoint_id" , "type" : "tag" },
170- {"name" : "channel" , "type" : "tag" },
171- {"name" : "version" , "type" : "tag" },
172- {"name" : "type" , "type" : "tag" },
173- ],
174- },
175- {
176- "index" : {
177- "name" : self ._checkpoint_write_prefix ,
178- "prefix" : self ._checkpoint_write_prefix + REDIS_KEY_SEPARATOR ,
179- "storage_type" : "json" ,
180- },
181- "fields" : [
182- {"name" : "thread_id" , "type" : "tag" },
183- {"name" : "checkpoint_ns" , "type" : "tag" },
184- {"name" : "checkpoint_id" , "type" : "tag" },
185- {"name" : "task_id" , "type" : "tag" },
186- {"name" : "idx" , "type" : "numeric" },
187- {"name" : "channel" , "type" : "tag" },
188- {"name" : "type" , "type" : "tag" },
189- ],
190- },
191- ]
192-
19389 self .configure_client (
19490 redis_url = redis_url ,
19591 redis_client = redis_client ,
@@ -202,6 +98,66 @@ def __init__(
20298 self .checkpoint_writes_index : IndexType
20399 self .create_indexes ()
204100
101+ @property
102+ def checkpoints_schema (self ) -> Dict [str , Any ]:
103+ """Schema for the checkpoints index."""
104+ return {
105+ "index" : {
106+ "name" : "checkpoints" ,
107+ "prefix" : self ._checkpoint_prefix + REDIS_KEY_SEPARATOR ,
108+ "storage_type" : "json" ,
109+ },
110+ "fields" : [
111+ {"name" : "thread_id" , "type" : "tag" },
112+ {"name" : "checkpoint_ns" , "type" : "tag" },
113+ {"name" : "checkpoint_id" , "type" : "tag" },
114+ {"name" : "parent_checkpoint_id" , "type" : "tag" },
115+ {"name" : "checkpoint_ts" , "type" : "numeric" },
116+ {"name" : "source" , "type" : "tag" },
117+ {"name" : "step" , "type" : "numeric" },
118+ {"name" : "has_writes" , "type" : "tag" },
119+ ],
120+ }
121+
122+ @property
123+ def blobs_schema (self ) -> Dict [str , Any ]:
124+ """Schema for the checkpoint blobs index."""
125+ return {
126+ "index" : {
127+ "name" : "checkpoints_blobs" ,
128+ "prefix" : self ._checkpoint_blob_prefix + REDIS_KEY_SEPARATOR ,
129+ "storage_type" : "json" ,
130+ },
131+ "fields" : [
132+ {"name" : "thread_id" , "type" : "tag" },
133+ {"name" : "checkpoint_ns" , "type" : "tag" },
134+ {"name" : "checkpoint_id" , "type" : "tag" },
135+ {"name" : "channel" , "type" : "tag" },
136+ {"name" : "version" , "type" : "tag" },
137+ {"name" : "type" , "type" : "tag" },
138+ ],
139+ }
140+
141+ @property
142+ def writes_schema (self ) -> Dict [str , Any ]:
143+ """Schema for the checkpoint writes index."""
144+ return {
145+ "index" : {
146+ "name" : "checkpoint_writes" ,
147+ "prefix" : self ._checkpoint_write_prefix + REDIS_KEY_SEPARATOR ,
148+ "storage_type" : "json" ,
149+ },
150+ "fields" : [
151+ {"name" : "thread_id" , "type" : "tag" },
152+ {"name" : "checkpoint_ns" , "type" : "tag" },
153+ {"name" : "checkpoint_id" , "type" : "tag" },
154+ {"name" : "task_id" , "type" : "tag" },
155+ {"name" : "idx" , "type" : "numeric" },
156+ {"name" : "channel" , "type" : "tag" },
157+ {"name" : "type" , "type" : "tag" },
158+ ],
159+ }
160+
205161 @abstractmethod
206162 def create_indexes (self ) -> None :
207163 """Create appropriate SearchIndex instances."""
0 commit comments