Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
exclude: '^telemetry/ui|^burr/tracking/server/demo_data(/|$)'
repos:
- repo: https://github.com/ambv/black
rev: 23.11.0
rev: 26.5.1
hooks:
- id: black
args: [--line-length=100]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
# burr/examples is a symlink. trailing-whitespace would mangle the
Expand All @@ -49,7 +49,7 @@ repos:
- id: check-ast
# isort python package import sorting
- repo: https://github.com/pycqa/isort
rev: '5.12.0'
rev: '9.0.0b2'
hooks:
- id: isort
args:
Expand All @@ -65,7 +65,7 @@ repos:
'burr',
]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.3.0
hooks:
- id: flake8
- repo: local
Expand Down
3 changes: 1 addition & 2 deletions burr/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,7 @@ class FunctionRepresentingAction(Protocol[C]):
action_function: FunctionBasedActionType
__call__: C

def bind(self, **kwargs: Any) -> Self:
...
def bind(self, **kwargs: Any) -> Self: ...


def copy_func(f: types.FunctionType) -> types.FunctionType:
Expand Down
12 changes: 4 additions & 8 deletions burr/core/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ def set_serde_kwargs(self, serde_kwargs: dict):
def create_table_if_not_exists(self, table_name: str):
"""Helper function to create the table where things are stored if it doesn't exist."""
cursor = self.connection.cursor()
cursor.execute(
f"""
cursor.execute(f"""
CREATE TABLE IF NOT EXISTS {table_name} (
partition_key TEXT DEFAULT '{SQLitePersister.PARTITION_KEY_DEFAULT}',
app_id TEXT NOT NULL,
Expand All @@ -416,13 +415,10 @@ def create_table_if_not_exists(self, table_name: str):
state TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (partition_key, app_id, sequence_id, position)
)"""
)
cursor.execute(
f"""
)""")
cursor.execute(f"""
CREATE INDEX IF NOT EXISTS {table_name}_created_at_index ON {table_name} (created_at);
"""
)
""")
self.connection.commit()

def initialize(self):
Expand Down
3 changes: 1 addition & 2 deletions burr/integrations/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def prompt_mapper(state):
class StateToPromptMapper(Protocol):
"""Protocol for mapping Burr state to Bedrock prompt format."""

def __call__(self, state: State) -> dict[str, Any]:
... # noqa: E704
def __call__(self, state: State) -> dict[str, Any]: ... # noqa: E704


def _text_from_content_blocks(content_blocks: list[Any]) -> str:
Expand Down
12 changes: 4 additions & 8 deletions burr/integrations/persisters/b_aiosqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ async def __aexit__(self, exc_type, exc_value, traceback):
async def create_table_if_not_exists(self, table_name: str):
"""Helper function to create the table where things are stored if it doesn't exist."""
cursor = await self.connection.cursor()
await cursor.execute(
f"""
await cursor.execute(f"""
CREATE TABLE IF NOT EXISTS {table_name} (
partition_key TEXT DEFAULT '{AsyncSQLitePersister.PARTITION_KEY_DEFAULT}',
app_id TEXT NOT NULL,
Expand All @@ -157,13 +156,10 @@ async def create_table_if_not_exists(self, table_name: str):
state TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (partition_key, app_id, sequence_id, position)
)"""
)
await cursor.execute(
f"""
)""")
await cursor.execute(f"""
CREATE INDEX IF NOT EXISTS {table_name}_created_at_index ON {table_name} (created_at);
"""
)
""")
await self.connection.commit()

async def initialize(self):
Expand Down
12 changes: 4 additions & 8 deletions burr/integrations/persisters/b_asyncpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ async def create_table(self, table_name: str):
conn, acquired = await self._get_connection()
try:
async with conn.transaction():
await conn.execute(
f"""
await conn.execute(f"""
CREATE TABLE IF NOT EXISTS {table_name} (
partition_key TEXT DEFAULT '{self.PARTITION_KEY_DEFAULT}',
app_id TEXT NOT NULL,
Expand All @@ -253,13 +252,10 @@ async def create_table(self, table_name: str):
state JSONB NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (partition_key, app_id, sequence_id, position)
)"""
)
await conn.execute(
f"""
)""")
await conn.execute(f"""
CREATE INDEX IF NOT EXISTS {table_name}_created_at_index ON {table_name} (created_at);
"""
)
""")
finally:
await self._release_connection(conn, acquired)

Expand Down
12 changes: 4 additions & 8 deletions burr/integrations/persisters/b_psycopg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def set_serde_kwargs(self, serde_kwargs: dict):
def create_table(self, table_name: str):
"""Helper function to create the table where things are stored."""
cursor = self.connection.cursor()
cursor.execute(
f"""
cursor.execute(f"""
CREATE TABLE IF NOT EXISTS {table_name} (
partition_key TEXT DEFAULT '{self.PARTITION_KEY_DEFAULT}',
app_id TEXT NOT NULL,
Expand All @@ -121,13 +120,10 @@ def create_table(self, table_name: str):
state JSONB NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (partition_key, app_id, sequence_id, position)
)"""
)
cursor.execute(
f"""
)""")
cursor.execute(f"""
CREATE INDEX IF NOT EXISTS {table_name}_created_at_index ON {table_name} (created_at);
"""
)
""")
self.connection.commit()

def initialize(self):
Expand Down
2 changes: 1 addition & 1 deletion burr/integrations/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def load_state_from_log_file(jsonl_log_file: str, app: Application) -> AppState:
record = Record(
state=json_line["state"],
action=json_line["action"],
result=json_line["result"]
result=json_line["result"],
# TODO -- add start time, end time
)
out.append(record)
Expand Down
1 change: 1 addition & 0 deletions burr/lifecycle/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

"""Base tooling, internal-facing, for lifecycle hooks. This is stolen from the
hamilton implementation, but significantly simplified."""

import asyncio
import collections
import inspect
Expand Down
16 changes: 10 additions & 6 deletions burr/tracking/s3client.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,16 @@ def post_application_create(
*metadata_path,
data=metadata,
metadata={
"parent_pointer": json.dumps(dataclasses.asdict(parent_pointer))
if parent_pointer is not None
else "None",
"spawning_parent_pointer": json.dumps(dataclasses.asdict(spawning_parent_pointer))
if spawning_parent_pointer is not None
else "None",
"parent_pointer": (
json.dumps(dataclasses.asdict(parent_pointer))
if parent_pointer is not None
else "None"
),
"spawning_parent_pointer": (
json.dumps(dataclasses.asdict(spawning_parent_pointer))
if spawning_parent_pointer is not None
else "None"
),
},
)

Expand Down
48 changes: 27 additions & 21 deletions burr/tracking/server/s3/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ def from_path(cls, path: str, created_date: datetime.datetime) -> "DataFile":
file_type = (
"graph"
if filename.endswith("graph.json")
else "metadata"
if filename.endswith("_metadata.json")
else "log"
else "metadata" if filename.endswith("_metadata.json") else "log"
)

# # Validate the date parts
Expand Down Expand Up @@ -397,12 +395,14 @@ async def _query_metadata_file(metadata_file: DataFile) -> dict:
spawning_parent_pointer_raw = response["Metadata"].get("spawning_parent_pointer")
return dict(
partition_key=metadata_file.partition_key,
parent_pointer=json.loads(parent_pointer_raw)
if parent_pointer_raw != "None"
else None,
spawning_parent_pointer=json.loads(spawning_parent_pointer_raw)
if spawning_parent_pointer_raw != "None"
else None,
parent_pointer=(
json.loads(parent_pointer_raw) if parent_pointer_raw != "None" else None
),
spawning_parent_pointer=(
json.loads(spawning_parent_pointer_raw)
if spawning_parent_pointer_raw != "None"
else None
),
)

out = await utils.gather_with_concurrency(
Expand Down Expand Up @@ -654,9 +654,11 @@ async def list_projects(self, request: fastapi.Request) -> Sequence[schema.Proje
name=project.name,
id=project.name,
uri=project.uri if project.uri is not None else "TODO",
last_written=latest_logfile.created_at
if latest_logfile is not None
else project.created_at,
last_written=(
latest_logfile.created_at
if latest_logfile is not None
else project.created_at
),
created=project.created_at,
num_apps=await Application.filter(project=project).count(),
)
Expand Down Expand Up @@ -704,9 +706,9 @@ async def list_apps(
partition_key=application.partition_key,
first_written=application.created_at,
last_written=last_written,
num_steps=application.logfile_count
if application.logfile_count is not None
else 0,
num_steps=(
application.logfile_count if application.logfile_count is not None else 0
),
tags={},
)
)
Expand Down Expand Up @@ -871,12 +873,16 @@ async def indexing_jobs(
status=indexing_job.status,
records_processed=indexing_job.records_processed,
metadata={
"project": indexing_job.index_status.project.name
if indexing_job.index_status
else "unknown",
"s3_highwatermark": indexing_job.index_status.s3_highwatermark
if indexing_job.index_status
else "unknown",
"project": (
indexing_job.index_status.project.name
if indexing_job.index_status
else "unknown"
),
"s3_highwatermark": (
indexing_job.index_status.s3_highwatermark
if indexing_job.index_status
else "unknown"
),
},
)
)
Expand Down
6 changes: 3 additions & 3 deletions burr/tracking/server/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class PartialStep(pydantic.BaseModel):
step_start_log: Optional[BeginEntryModel] = fields.Field(default_factory=lambda: None)
step_end_log: Optional[EndEntryModel] = fields.Field(default_factory=lambda: None)
spans: List[Span] = fields.Field(default_factory=list)
streaming_events: List[
Union[InitializeStreamModel, FirstItemStreamModel, EndStreamModel]
] = fields.Field(default_factory=list)
streaming_events: List[Union[InitializeStreamModel, FirstItemStreamModel, EndStreamModel]] = (
fields.Field(default_factory=list)
)


class Step(pydantic.BaseModel):
Expand Down
6 changes: 2 additions & 4 deletions examples/conversational-rag/graph_db_example/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,10 @@ def build_application(


if __name__ == "__main__":
print(
"""Run
print("""Run
> burr
in another terminal to see the UI at http://localhost:7241
"""
)
""")
_client = openai.OpenAI()
_db_client = FalkorDB(host="localhost", port=6379)
_graph_name = "UFC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
Hamilton pipeline to load fighter data into FalkorDB.
"""

import falkordb
import pandas as pd
import utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
Hamilton module to ingest fight data into FalkorDB.
"""

import falkordb
import pandas as pd
import utils
Expand Down
1 change: 1 addition & 0 deletions examples/conversational-rag/graph_db_example/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
Code courtesy of the FalkorDB.
"""

from datetime import datetime


Expand Down
1 change: 1 addition & 0 deletions examples/custom-serde/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
and then
burr-test-case create --project-name serde-example --app-id APP_ID --sequence-id 3 --serde-module application.py
"""

import pprint
import uuid

Expand Down
1 change: 1 addition & 0 deletions examples/deep-researcher/deep_researcher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Based on code from https://github.com/langchain-ai/local-deep-researcher/tree/005db90331e116eb3edb4e9b43822136b211444e/src/ollama_deep_researcher
Copied under the MIT License.
"""

import logging

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions examples/deployment/vercel/api/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Vercel Serverless Function for counter application
Endpoint: /api/counter
"""

import json
from http.server import BaseHTTPRequestHandler

Expand Down
1 change: 1 addition & 0 deletions examples/hello-world-counter/application_classbased.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
Class based action example.
"""

import logging
from typing import List, Optional

Expand Down
1 change: 1 addition & 0 deletions examples/image-telephone/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- https://hub.dagworks.io/docs/Users/elijahbenizzy/caption_images/
- https://hub.dagworks.io/docs/Users/elijahbenizzy/generate_images/
"""

import os
import uuid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
plugin to provide some syntactic sugar for defining actions that run
Hamilton DAGs.
"""

import os
import uuid

Expand Down
1 change: 1 addition & 0 deletions examples/ml-training/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

Note: this example uses the class based API to define the actions. You could also use the function+decorator API.
"""

import burr.core.application
from burr.core import Action, Condition, State, default

Expand Down
1 change: 1 addition & 0 deletions examples/multi-agent-collaboration/hamilton/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
This also adds a tracer to the Hamilton DAG to trace the execution of the nodes
within the Action so that they also show up in the Burr UI.
"""

import json
from typing import Any, Dict, Optional

Expand Down
Loading
Loading