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
10 changes: 5 additions & 5 deletions burr/integrations/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

def model_to_dict(model: pydantic.BaseModel, include: Optional[List[str]] = None) -> dict:
"""Utility function to convert a pydantic model to a dictionary."""
keys = model.model_fields.keys()
keys = keys if include is None else [item for item in include if item in model.model_fields]
keys = type(model).model_fields.keys()
keys = keys if include is None else [item for item in include if item in type(model).model_fields]
return {key: getattr(model, key) for key in keys}


Expand All @@ -76,7 +76,7 @@ def subset_model(
"""
new_fields = {}

for name, field_info in model.model_fields.items():
for name, field_info in type(model).model_fields.items():
if name in fields:
# copy directly
# TODO -- handle cross-field validation
Expand Down Expand Up @@ -114,7 +114,7 @@ def model_from_state(model: Type[ModelType], state: State) -> ModelType:
:param state: state object to create from
:return: model object
"""
keys = [item for item in model.model_fields.keys() if item in state]
keys = [item for item in type(model).model_fields.keys() if item in state]
return model(**{key: state[key] for key in keys})


Expand Down Expand Up @@ -153,7 +153,7 @@ def _validate_and_extract_signature_types(


def _validate_keys(model: Type[pydantic.BaseModel], keys: List[str], fn: Callable) -> None:
missing_keys = [key for key in keys if key not in model.model_fields]
missing_keys = [key for key in keys if key not in type(model).model_fields]
if missing_keys:
raise ValueError(
f"Function fn: {fn.__qualname__} is not a valid pydantic action. "
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tests = [
"langchain_core",
"langchain_community",
"pandas",
"pydantic[email]",
"pydantic[email]>=2.11",
"pyarrow",
"apache-burr[aiosqlite]",
"apache-burr[asyncpg]",
Expand Down Expand Up @@ -120,7 +120,7 @@ documentation = [
]

tracking-client = [
"pydantic>1"
"pydantic>=2.11"
]

tracking-client-s3 = [
Expand All @@ -141,7 +141,7 @@ tracking-server = [
"click",
"fastapi",
"uvicorn",
"pydantic",
"pydantic>=2.11",
"pydantic-settings",
"fastapi-pagination",
"fastapi-utils",
Expand All @@ -153,7 +153,7 @@ tracking-server = [
]

pydantic = [
"pydantic"
"pydantic>=2.11"
]

haystack = [
Expand Down