-
Notifications
You must be signed in to change notification settings - Fork 377
refactor: PersistentObject abstraction #1172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
1186ca2
to
c1f920c
Compare
@@ -1,6 +1,6 @@ | |||
# ruff: noqa: A005 | |||
|
|||
from ._models import FinalStatistics, StatisticsPersistedState, StatisticsState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could revert removing this one for BC, but honestly, having it exported feels like a bug to me.
@@ -78,33 +78,3 @@ def test_session_model( | |||
|
|||
# Check that max_age is correctly parsed into a timedelta object | |||
assert session_direct.max_age == session_camel.max_age == session_snake.max_age == timedelta(minutes=30) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new models, this didn't really test anything (except that assignment works..)
TStateModel = TypeVar('TStateModel', bound=BaseModel) | ||
|
||
|
||
class PersistentObject(Generic[TStateModel]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PersistentObject
name creates impression of unconditional persistence, but PersistentObject(...persistence_enabled=False) is basically creating "NonPersitentObejct"
Same goes for usage in other classes that set persistence_enabled=False and then internally they use PersitentObject regardless.
Maybe it should have some name that hints about the persistence possibility. Maybe PersitableObject
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. On the other hand, PersistableObject
would suggest that you need to do something to actually persist it, at least for me. Brainstorm time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude's suggestions kinda disappointed me... But I guess we could also work with words like "Checkpointing" or "Recoverable"
It would make a lot of sense to use the same abstraction for autosaved values in KeyValueStore |
Statistics
andSessionPool
).Key Changes
Introduced a new
PersistentObject
helper class that:KeyValueStore
Refactored existing components to use the new abstraction:
SessionPool
to usePersistentObject
for state managementStatistics
to usePersistentObject
for state managementBenefits