Skip to content

Commit 5540b45

Browse files
pseusysRLKRopseusys
authored
Partial context updates (#93)
# Description Context storages are updated partially now instead of reading and writing whole data at once. # Checklist - [x] I have covered the code with tests - [x] I have added comments to my code to help others understand it - [x] I have updated the documentation to reflect the changes - [x] I have performed a self-review of the changes - [x] Consider extending `UpdateScheme` from `BaseModel` - [x] Decide how we want to use `clear` method. --------- Co-authored-by: Roman Zlobin <[email protected]> Co-authored-by: = <=> Co-authored-by: pseusys <[email protected]>
1 parent 5c05693 commit 5540b45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3501
-1606
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
dist/
44
venv/
55
build/
6+
dbs/
67
docs/source/apiref
78
docs/source/_misc
89
docs/source/release_notes.rst

chatsky/__rebuild_pydantic_models__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
from chatsky.core.script import Node
66
from chatsky.core.pipeline import Pipeline
77
from chatsky.slots.slots import SlotManager
8-
from chatsky.core.context import FrameworkData, ServiceState
8+
from chatsky.context_storages import DBContextStorage
9+
from chatsky.core.ctx_dict import ContextDict
10+
from chatsky.core.ctx_utils import ServiceState, FrameworkData, ContextMainInfo
911
from chatsky.core.service import PipelineComponent
1012

13+
ContextMainInfo.model_rebuild()
14+
ContextDict.model_rebuild()
1115
PipelineComponent.model_rebuild()
1216
Pipeline.model_rebuild()
1317
Script.model_rebuild()

chatsky/conditions/standard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __init__(
202202
super().__init__(flow_labels=flow_labels, labels=labels, last_n_indices=last_n_indices)
203203

204204
async def call(self, ctx: Context) -> bool:
205-
labels = list(ctx.labels.values())[-self.last_n_indices :] # noqa: E203
205+
labels = await ctx.labels.get(ctx.labels.keys()[-self.last_n_indices :]) # noqa: E203
206206
for label in labels:
207207
if label.flow_name in self.flow_labels or label in self.labels:
208208
return True
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22

3-
from .database import DBContextStorage, threadsafe_method, context_storage_factory
4-
from .json import JSONContextStorage, json_available
5-
from .pickle import PickleContextStorage, pickle_available
3+
from .database import DBContextStorage, context_storage_factory
4+
from .file import JSONContextStorage, PickleContextStorage, ShelveContextStorage, json_available, pickle_available
65
from .sql import SQLContextStorage, postgres_available, mysql_available, sqlite_available, sqlalchemy_available
76
from .ydb import YDBContextStorage, ydb_available
87
from .redis import RedisContextStorage, redis_available
8+
from .memory import MemoryContextStorage
99
from .mongo import MongoContextStorage, mongo_available
10-
from .shelve import ShelveContextStorage
1110
from .protocol import PROTOCOLS, get_protocol_install_suggestion

0 commit comments

Comments
 (0)