Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
added suggested changes
Gupta Arpit3fe077958b6a
diff --git a/burr/core/application.py b/burr/core/application.pyindex 0e70f785..7acd61f2 100644--- a/burr/core/application.py+++ b/burr/core/application.py@@ -2249,13 +2249,14 @@ class ApplicationBuilder(Generic[StateType]):if on_every != "step":raise ValueError(f"on_every {on_every} not supported")- # Check if 'is_initialized' exists and whether it returns False, indicating the persister is uninitialized- if hasattr(persister, 'is_initialized'):+ # Check if 'is_initialized' exists and is False; raise RuntimeError, else continue if not implemented+ try:if not persister.is_initialized():raise RuntimeError("RuntimeError: Uninitialized persister. Make sure to call .initialize() before passing it to the ApplicationBuilder")- # If the persister is valid and initialized, add it to lifecycle adapters+ except NotImplementedError:+ passif not isinstance(persister, persistence.BaseStateSaver):self.lifecycle_adapters.append(persister)else:diff --git a/tests/core/test_application.py b/tests/core/test_application.pyindex 11256f16..de4cab08 100644--- a/tests/core/test_application.py+++ b/tests/core/test_application.py@@ -3230,3 +3230,15 @@ def test_builder_captures_typing_system():_, _, state = app.run(halt_after=["result"])assert isinstance(state.data, CounterState)assert state.data["count"] == 10++# Define a mock persister that does not implement is_initialized+class PersisterWithoutIsInitialized:+ def initialize(self):+ pass++def test_with_state_persister_no_is_initialized_method():+ builder = ApplicationBuilder()+ persister = PersisterWithoutIsInitialized()++ # Add the persister to the builder, expecting no exceptions+ builder.with_state_persister(persister)\ No newline at end of file