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
Add is_initialized() to base persister interface for compatibility
Gupta Arpit2e02985e5861
diff --git a/burr/core/application.py b/burr/core/application.pyindex ec324544..0e70f785 100644--- a/burr/core/application.py+++ b/burr/core/application.py@@ -2248,10 +2248,14 @@ class ApplicationBuilder(Generic[StateType]):"""if on_every != "step":raise ValueError(f"on_every {on_every} not supported")- if hasattr(persister, 'initialize') and not persister.is_initialized():- raise RuntimeError(- "Uninitialized persister. Make sure to call .initialize() before passing it to the ApplicationBuilder."- )++ # Check if 'is_initialized' exists and whether it returns False, indicating the persister is uninitialized+ if hasattr(persister, 'is_initialized'):+ 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 adaptersif not isinstance(persister, persistence.BaseStateSaver):self.lifecycle_adapters.append(persister)else:diff --git a/burr/core/persistence.py b/burr/core/persistence.pyindex 966c0c52..bb51da5d 100644--- a/burr/core/persistence.py+++ b/burr/core/persistence.py@@ -88,7 +88,11 @@ class BaseStatePersister(BaseStateLoader, BaseStateSaver, metaclass=ABCMeta):Extend this class if you want an easy way to implement custom state storage."""- pass+ def is_initialized(self) -> bool:+ """Check if the persister has been initialized. Default behavior is False.+ Persisters that require initialization can override this method.+ """+ return Falseclass PersisterHook(PostRunStepHook):