Skip to content
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

Formally adds state persistence #73

Merged
merged 13 commits into from
Mar 18, 2024
Merged

Formally adds state persistence #73

merged 13 commits into from
Mar 18, 2024

Conversation

skrawcz
Copy link
Contributor

@skrawcz skrawcz commented Mar 15, 2024

This does a few things:

  1. adds interface for persister and SQLLite implementation.
  2. pushes app_id, and partition_key through to App and hooks for (1)
  3. moves sequence ID incrementing to the start of a step to avoid bad restarts; we were only incrementing after saving which was bad.
  4. shows API in counter example with changes to builder required to facilitate the above.
  5. Adds basic docs (with TODOs to fill them out)
  6. Stubs out modifying the local tracking client -- main question here is does it handle partition key or not?

elijahbenizzy added a commit that referenced this pull request Mar 15, 2024
elijahbenizzy added a commit that referenced this pull request Mar 15, 2024
@skrawcz skrawcz changed the title WIP: adding persister Formally adds state persistence Mar 16, 2024
@skrawcz skrawcz marked this pull request as ready for review March 16, 2024 00:23
@skrawcz skrawcz force-pushed the add_persister branch 3 times, most recently from f157f50 to ade5e91 Compare March 16, 2024 06:40
Copy link
Contributor

@elijahbenizzy elijahbenizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, big things:

  1. Persistence handling failure is confusing me quite a bit, and we don't actually use it
  2. Sequence IDs are going to start at 1 (unless I'm mistaken)
  3. API is confusing me -- maybe docs will clear this up? We have trackers, persisters, initialize_from, etc... and its far from obvious which does which. Might need to revisit.
  4. Docs, remove a few TODOs prior to merge

burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
docs/main.rst Outdated Show resolved Hide resolved
docs/reference/persister.rst Show resolved Hide resolved
examples/counter/application.py Outdated Show resolved Hide resolved
examples/multi-agent-collaboration/hamilton_application.py Outdated Show resolved Hide resolved
@elijahbenizzy elijahbenizzy mentioned this pull request Mar 16, 2024
@elijahbenizzy elijahbenizzy self-requested a review March 18, 2024 23:09
Copy link
Contributor

@elijahbenizzy elijahbenizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged in #75 -- this has all the changes we discussed. Also adds partition key to UI.

skrawcz and others added 12 commits March 18, 2024 16:11
This does a few things:

1. adds interface for persister and SQLLite implementation.
2. pushes app_id, and partition_key through to App and hooks for (1)
3. moves sequence ID incrementing to the start of a step to avoid
bad restarts; we were only incrementing after saving which was bad.
4. shows API in counter example with changes to builder required
to facilitate the above.

TODOs:
 - test updates
 - docs
 - modifying tracker
So the return of load was getting out of hand. Added
TypedDict response. I feel like that's a bit easier to extend.

Also decided that save should have a status field. So
the persister can make a choice whether to save it or not,
and then likewise when loading someone can determine
what behavior they want.

Otherwise possible edge cases / bugs to iron out:

 - async/streaming -- not tested
 - sequence id needs to be done prior to the step
 - also reloading from an error nuking  `__prior_step` means
that it isn't set until the third iteration weirdly. Haven't had a chance
to dig.
I think this should minimally cover things.
I also refactored things to be more readable.
This changes the with_tracker signature to check if the
thing being passed has hooks and can be added
as a lifecycle adapter.

Otherwise this cleans up some imports and stubs
out the functions to make the local tracking client
also a persister.
This mostly adds TODOs but it sets up the structure.
This shows how to quickly implement something that
will create "spans" in the burr UI for the given framework.
Following changes:
1. Makes the state the source of truth in applications
2. Adds error-checking on the initialize API
3. Breaks up the persistor API to multiple pieces to allow for the
   tracking client to use it
4. Adds misc docs/cleans up
This adds the partition key in a new metadata.json file in the
application directory. This defaults to None (valid) if empty, so we're
backwards compatible.
@elijahbenizzy elijahbenizzy merged commit 5b9917a into main Mar 18, 2024
6 checks passed
@elijahbenizzy elijahbenizzy deleted the add_persister branch March 18, 2024 23:22
elijahbenizzy added a commit that referenced this pull request Mar 18, 2024
elijahbenizzy added a commit that referenced this pull request Mar 19, 2024
elijahbenizzy added a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants