Skip to content
Merged
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
17 changes: 11 additions & 6 deletions src/guidellm/schemas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ def reload_schema(cls, parents: bool = True) -> None:
@classmethod
def reload_parent_schemas(cls):
"""
Recursively reload schemas for all parent Pydantic models.
Recursively reload schemas for all Pydantic models that reference this
Comment thread
dbutenhof marked this conversation as resolved.
class in their field annotations.

Traverses the inheritance hierarchy to find all parent classes that
are Pydantic models and triggers schema rebuilding on each to ensure
that any changes in child models are reflected in parent schemas.
Walks the subclass trees of guidellm's own model roots
(ReloadableBaseModel and StandardBaseModel) rather than all BaseModel
subclasses, so third-party Pydantic models loaded in the same process
are not visited.
"""
potential_parents: set[type[BaseModel]] = {BaseModel}
stack: list[type[BaseModel]] = [BaseModel]
potential_parents: set[type[BaseModel]] = {
ReloadableBaseModel,
StandardBaseModel,
}
stack: list[type[BaseModel]] = list(potential_parents)

while stack:
current = stack.pop()
Expand Down