Skip to content

Commit

Permalink
fix: config default root models to allow new API fields
Browse files Browse the repository at this point in the history
This doesn't automatically bring support for any intended functionality but in the case of informational model dumps, such as for the `skipped` info on a job pop or user/worker info responses this will allow some forwards compatibility in the case new fields are added to already known API models.
  • Loading branch information
tazlin committed Oct 5, 2024
1 parent 7912776 commit 2d3530f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion horde_sdk/ai_horde_api/apimodels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ class ImageGenerateParamMixin(HordeAPIDataObject):
"""

model_config = (
ConfigDict(frozen=True) if not os.getenv("TESTS_ONGOING") else ConfigDict(frozen=True, extra="forbid")
ConfigDict(frozen=True, extra="allow")
if not os.getenv("TESTS_ONGOING")
else ConfigDict(frozen=True, extra="forbid")
)

sampler_name: KNOWN_SAMPLERS | str = KNOWN_SAMPLERS.k_lms
Expand Down
5 changes: 4 additions & 1 deletion horde_sdk/generic_api/apimodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class HordeAPIDataObject(BaseModel):
ConfigDict(
frozen=True,
use_attribute_docstrings=True,
extra="allow",
)
if not os.getenv("TESTS_ONGOING")
else ConfigDict(
Expand Down Expand Up @@ -98,7 +99,9 @@ class HordeResponseBaseModel(HordeResponse, BaseModel):
"""Base class for all Horde API response data models (leveraging pydantic)."""

model_config = (
ConfigDict(frozen=True) if not os.getenv("TESTS_ONGOING") else ConfigDict(frozen=True, extra="forbid")
ConfigDict(frozen=True, extra="allow")
if not os.getenv("TESTS_ONGOING")
else ConfigDict(frozen=True, extra="forbid")
)


Expand Down

0 comments on commit 2d3530f

Please sign in to comment.