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
Fixes picking up from null sequence ID
elijahbenizzy677afa919f64
diff --git a/burr/tracking/client.py b/burr/tracking/client.pyindex a474f5f6..825d352a 100644--- a/burr/tracking/client.py+++ b/burr/tracking/client.py@@ -326,8 +326,6 @@ class LocalTrackingClient(# TODO:if app_id is None:return # no application ID- if sequence_id is None:- sequence_id = -1 # get the last onepath = os.path.join(self.storage_dir, app_id, self.LOG_FILENAME)if not os.path.exists(path):return None@@ -339,10 +337,16 @@ class LocalTrackingClient(json_lines = [json.loads(js_line) for js_line in json_lines]# filter to only end_entryline = None- for js_line in json_lines:- if js_line["type"] == "end_entry":- if js_line["sequence_id"] == sequence_id:- line = js_line+ if sequence_id is None:+ # get the last one, we want to start at the end+ line = json_lines[-1]+ sequence_id = line["sequence_id"]+ else:+ for js_line in json_lines:+ if js_line["type"] == "end_entry":+ if js_line["sequence_id"] == sequence_id:+ line = js_line+if line is None:raise ValueError(f"Sequence number {sequence_id} not found for {self.project_id}/{app_id}."diff --git a/tests/tracking/test_local_tracking_client.py b/tests/tracking/test_local_tracking_client.pyindex 78fb9b73..335b974e 100644--- a/tests/tracking/test_local_tracking_client.py+++ b/tests/tracking/test_local_tracking_client.py@@ -284,3 +284,16 @@ def test_multi_fork_tracking_client(tmpdir):assert forked_app_2.parent_pointer.app_id == forked_app_idassert forked_app_2.parent_pointer.sequence_id == 10++ # fork from latest+ # TODO -- break this up -- this test tests too much at once+ # This is a quick addition to test that forking from sequence_id=None picks up where the last one left off++ forked_forked_forked_app_id = f"fork_3_{common_app_id}"+ forked_app_3, tracker = create_application(+ forked_forked_app_id, forked_forked_forked_app_id, None, max_count=35+ )+ assert (+ forked_app_3.sequence_id == forked_app_2.sequence_id == 25+ ) # this should pick up where the last one left off+ assert forked_app_3.parent_pointer.app_id == forked_forked_app_id