Skip to content

Commit

Permalink
Merge pull request #255 from Haidra-Org/main
Browse files Browse the repository at this point in the history
fix: explicitly specify `default` arg for pydantic `Field`s
  • Loading branch information
tazlin authored Sep 21, 2024
2 parents 0244ed5 + cc75d63 commit 3e705dc
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 135 deletions.
10 changes: 5 additions & 5 deletions horde_sdk/ai_horde_api/apimodels/_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ImageStatsModelsRequest(BaseAIHordeRequest):
)

model_state: MODEL_STATE = Field(
MODEL_STATE.all,
default=MODEL_STATE.all,
)
"""The state of the models to get stats for. Known models are models that are known to the system."""

Expand All @@ -124,11 +124,11 @@ def get_default_success_response_type(cls) -> type[ImageStatsModelsResponse]:

class SinglePeriodImgStat(HordeAPIDataObject):
images: int | None = Field(
None,
default=None,
)
"""The amount of images generated during this period."""
ps: int | None = Field(
None,
default=None,
)
"""The amount of pixelsteps generated during this period."""

Expand Down Expand Up @@ -255,11 +255,11 @@ def get_default_success_response_type(cls) -> type[TextStatsModelResponse]:

class SinglePeriodTxtStat(HordeAPIDataObject):
requests: int | None = Field(
None,
default=None,
)
"""The number of requests made during this period."""
tokens: int | None = Field(
None,
default=None,
)
"""The number of tokens generated during this period."""

Expand Down
52 changes: 26 additions & 26 deletions horde_sdk/ai_horde_api/apimodels/_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def get_default_success_response_type(cls) -> type[AIHordeHeartbeatResponse]:

class HordePerformanceResponse(HordeResponseBaseModel):
interrogator_count: int | None = Field(
None,
default=None,
description=(
"How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes."
),
)
"""How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes."""
interrogator_thread_count: int | None = Field(
None,
default=None,
description=(
"How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5"
" minutes."
Expand All @@ -66,35 +66,35 @@ class HordePerformanceResponse(HordeResponseBaseModel):
"""How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5
minutes."""
past_minute_megapixelsteps: float | None = Field(
None,
default=None,
)
"""How many megapixelsteps this horde generated in the last minute."""
past_minute_tokens: float | None = Field(
None,
default=None,
)
"""How many tokens this horde generated in the last minute."""
queued_forms: float | None = Field(
None,
default=None,
)
"""The amount of image interrogations waiting and processing currently in this horde."""
queued_megapixelsteps: float | None = Field(
None,
default=None,
)
"""The amount of megapixelsteps in waiting and processing requests currently in this horde."""
queued_requests: int | None = Field(
None,
default=None,
)
"""The amount of waiting and processing image requests currently in this horde."""
queued_text_requests: int | None = Field(
None,
default=None,
)
"""The amount of waiting and processing text requests currently in this horde."""
queued_tokens: float | None = Field(
None,
default=None,
)
"""The amount of tokens in waiting and processing requests currently in this horde."""
text_thread_count: int | None = Field(
None,
default=None,
description=(
"How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5"
" minutes."
Expand All @@ -103,11 +103,11 @@ class HordePerformanceResponse(HordeResponseBaseModel):
"""How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5
minutes."""
text_worker_count: int | None = Field(
None,
default=None,
)
"""How many workers are actively processing prompt generations in this horde in the past 5 minutes."""
thread_count: int | None = Field(
None,
default=None,
description=(
"How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5"
" minutes."
Expand All @@ -116,7 +116,7 @@ class HordePerformanceResponse(HordeResponseBaseModel):
"""How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5
minutes."""
worker_count: int | None = Field(
None,
default=None,
)
"""How many workers are actively processing prompt generations in this horde in the past 5 minutes."""

Expand Down Expand Up @@ -150,13 +150,13 @@ def get_default_success_response_type(cls) -> type[HordePerformanceResponse]:

class Newspiece(HordeAPIObject):
date_published: str | None = Field(
None,
default=None,
)
"""The date this newspiece was published."""
importance: str | None = Field(None, examples=["Information"])
importance: str | None = Field(default=None, examples=["Information"])
"""How critical this piece of news is."""
newspiece: str | None = Field(
None,
default=None,
)
"""The actual piece of news."""

Expand Down Expand Up @@ -212,11 +212,11 @@ def get_default_success_response_type(cls) -> type[NewsResponse]:

class ActiveModelLite(HordeAPIObject):
count: int | None = Field(
None,
default=None,
)
"""How many of workers in this horde are running this model."""
name: str | None = Field(
None,
default=None,
)
"""The Name of a model available by workers in this horde."""

Expand All @@ -228,19 +228,19 @@ def get_api_model_name(cls) -> str | None:

class ActiveModel(ActiveModelLite):
eta: int | None = Field(
None,
default=None,
)
"""Estimated time in seconds for this model's queue to be cleared."""
jobs: float | None = Field(
None,
default=None,
)
"""The job count waiting to be generated by this model."""
performance: float | None = Field(
None,
default=None,
)
"""The average speed of generation for this model."""
queued: float | None = Field(
None,
default=None,
)
"""The amount waiting to be generated by this model."""
type_: MODEL_TYPE | None = Field(
Expand Down Expand Up @@ -283,7 +283,7 @@ class HordeStatusModelsAllRequest(BaseAIHordeRequest):
)

type_: MODEL_TYPE = Field(
MODEL_TYPE.image,
default=MODEL_TYPE.image,
examples=[MODEL_TYPE.image, MODEL_TYPE.text],
alias="type",
)
Expand Down Expand Up @@ -379,17 +379,17 @@ def get_default_success_response_type(cls) -> type[HordeStatusModelsSingleRespon

class HordeModes(HordeAPIObject):
maintenance_mode: bool = Field(
False,
default=False,
)
"""Whether the horde is in maintenance mode."""

invite_only_mode: bool = Field(
False,
default=False,
)
"""Whether the horde is in invite-only mode."""

raid_mode: bool = Field(
False,
default=False,
)
"""Whether the horde is in raid mode."""

Expand Down
42 changes: 21 additions & 21 deletions horde_sdk/ai_horde_api/apimodels/_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,21 @@ def get_default_success_response_type(cls) -> type[UserDetailsResponse]:

class _ModifyUserBase(HordeAPIDataObject):
admin_comment: str | None = Field(
None,
default=None,
max_length=500,
min_length=5,
)
"""Add further information about this user for the other admins."""

concurrency: int | None = Field(
None,
default=None,
ge=0,
le=500,
)
"""The amount of concurrent request this user can have."""

contact: str | None = Field(
None,
default=None,
examples=["[email protected]"],
max_length=500,
min_length=5,
Expand All @@ -358,94 +358,94 @@ class _ModifyUserBase(HordeAPIDataObject):
moderators."""

customizer: bool | None = Field(
None,
default=None,
)
"""When set to true, the user will be able to serve custom Stable Diffusion models which do not exist in the
Official AI Horde Model Reference."""

education: bool | None = Field(
None,
default=None,
)
"""When set to true, the user is considered an education account and some options become more restrictive."""

filtered: bool | None = Field(
None,
default=None,
)
"""When set to true, the replacement filter will always be applied against this user"""

flagged: bool | None = Field(
None,
default=None,
)
"""When set to true, the user cannot transfer kudos and all their workers are put into permanent maintenance."""

moderator: bool | None = Field(
None,
default=None,
)
"""Set to true to make this user a horde moderator."""

monthly_kudos: int | None = Field(
None,
default=None,
)
"""When specified, will start assigning the user monthly kudos, starting now!"""

public_workers: bool | None = Field(
None,
default=None,
)
"""Set to true to make this user display their worker IDs."""

service: bool | None = Field(
None,
default=None,
)
"""When set to true, the user is considered a service account proxying the requests for other users."""

special: bool | None = Field(
None,
default=None,
)
"""When set to true, The user can send special payloads."""

trusted: bool | None = Field(
None,
default=None,
)
"""When set to true,the user and their servers will not be affected by suspicion."""

usage_multiplier: float | None = Field(
None,
default=None,
ge=0.1,
le=10.0,
)
"""The amount by which to multiply the users kudos consumption."""

username: str | None = Field(
None,
default=None,
max_length=100,
min_length=3,
)
"""When specified, will change the username. No profanity allowed!"""

vpn: bool | None = Field(
None,
default=None,
)
"""When set to true, the user will be able to onboard workers behind a VPN. This should be used as a temporary
solution until the user is trusted."""

worker_invited: int | None = Field(
None,
default=None,
)
"""Set to the amount of workers this user is allowed to join to the horde when in worker invite-only mode."""


class ModifyUser(_ModifyUserBase):
kudos: float | None = Field(None)
kudos: float | None = Field(default=None)
"""The amount of kudos to modify (can be negative)."""

reset_suspicion: bool | None = Field(None)
reset_suspicion: bool | None = Field(default=None)
"""Set the user's suspicion back to 0."""


class ModifyUserReply(_ModifyUserBase):
new_kudos: float | None = Field(None)
new_kudos: float | None = Field(default=None)
"""The new amount of kudos this user has."""
new_suspicion: int | None = Field(None)
new_suspicion: int | None = Field(default=None)
"""The new amount of suspicion this user has."""


Expand Down
10 changes: 5 additions & 5 deletions horde_sdk/ai_horde_api/apimodels/alchemy/_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def validate_form(cls, v: str | KNOWN_ALCHEMY_TYPES) -> KNOWN_ALCHEMY_TYPES | st
payload: AlchemyFormPayloadStable | None = None
"""The setting for this interrogation form."""
r2_upload: str | None = Field(
None,
default=None,
)
"""The URL in which the post-processed image can be uploaded."""
source_image: str | None = Field(
None,
default=None,
)
"""The URL From which the source image can be downloaded."""

Expand All @@ -88,7 +88,7 @@ def get_api_model_name(cls) -> str | None:
return "NoValidInterrogationsFoundStable"

bridge_version: int | None = Field(
None,
default=None,
description=(
"How many waiting requests were skipped because they require a higher version of the bridge than this"
" worker is running (upgrade if you see this in your skipped list)."
Expand All @@ -99,15 +99,15 @@ def get_api_model_name(cls) -> str | None:
"""How many waiting requests were skipped because they require a higher version of the bridge than this worker is
running (upgrade if you see this in your skipped list)."""
untrusted: int | None = Field(
None,
default=None,
description=(
"How many waiting requests were skipped because they demanded a trusted worker which this worker is not."
),
ge=0,
)
"""How many waiting requests were skipped because they demanded a trusted worker which this worker is not."""
worker_id: int | None = Field(
None,
default=None,
ge=0,
)
"""How many waiting requests were skipped because they demanded a specific worker."""
Expand Down
Loading

0 comments on commit 3e705dc

Please sign in to comment.