Skip to content

Conversation

@Smitaambiger
Copy link

@skrawcz Related to #416

This PR adds an optional override_state_values parameter to ApplicationBuilder.initialize_from, allowing callers to override or augment state values when initializing from a persisted state.

Changes

  • Added override_state_values parameter to initialize_from
  • Stored override values on the builder
  • Applied overrides after persisted state is loaded

How I tested this

  • Reviewed the state initialization and persistence flow
  • Verified that override values are applied after loading persisted state
  • Confirmed existing behavior is unchanged when overrides are not provided

Notes

This change is backward-compatible and only applies when
override_state_values is explicitly passed.

@skrawcz
Copy link
Contributor

skrawcz commented Jan 16, 2026

@Smitaambiger cool. Can you add a unit test for this please?

@Smitaambiger
Copy link
Author

@skrawcz
Thanks for the review!
Sure — I’ll add a unit test covering override_state_values and update the docs as needed.

@Smitaambiger
Copy link
Author

@skrawcz
I’ve added a unit test covering override_state_values in initialize_from.

Please let me know if you’d like the test structured differently or placed elsewhere. Happy to update!

Comment on lines 3730 to 3732
from burr.core.application import ApplicationBuilder
from burr.core.state import State
from burr.core.persistence import BaseStateLoader
Copy link
Contributor

Choose a reason for hiding this comment

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

can you remove these imports -- there should be no need for them. If they are missing add them to the top please.

# there was something
last_position = load_result["position"]
self.state = load_result["state"]
if getattr(self, "override_state_values", None):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is overly defensive. Logically this should always resolve given this change.

Suggested change
if getattr(self, "override_state_values", None):
if self.override_state_values:

Copy link
Contributor

@skrawcz skrawcz left a comment

Choose a reason for hiding this comment

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

Thanks. Some minor clean up please.

@skrawcz
Copy link
Contributor

skrawcz commented Jan 19, 2026

@Smitaambiger your test also fails:

FAILED tests/core/test_application.py::test_initialize_from_applies_override_state_values - TypeError: Can't instantiate abstract class FakeStateLoader with abstract method list_app_ids

@Smitaambiger
Copy link
Author

@skrawcz Thanks for the review!

I’ve addressed the requested cleanup and test failure:

  • Implemented list_app_ids on FakeStateLoader to satisfy the abstract base class
  • Updated the test to respect initialize_from entrypoint rules
  • Simplified the override_state_values check as suggested
  • Removed unnecessary inline imports

I verified the change locally with:

pytest tests/core/test_application.py -k override_state_values

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======== 1 passed, 124 deselected, 2 warnings in 0.60s ========= 

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