Skip to content

Commit

Permalink
Merge pull request #145 from Haidra-Org/main
Browse files Browse the repository at this point in the history
fix: skipped logic
  • Loading branch information
tazlin authored Feb 17, 2024
2 parents 43317ab + 241e908 commit 6ee058b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion horde_sdk/ai_horde_api/apimodels/generate/_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def validate_id(cls, v: str | JobID) -> JobID | str:
@model_validator(mode="after")
def ids_present(self) -> ImageGenerateJobPopResponse:
"""Ensure that either id_ or ids is present."""
if self.skipped.is_empty() and self.model is None:
if self.model is None:
if self.skipped.is_empty():
logger.debug("No model or skipped data found in response.")
else:
logger.debug("No model found in response.")
return self

if self.id_ is None and len(self.ids) == 0:
Expand Down
30 changes: 30 additions & 0 deletions tests/ai_horde_api/test_ai_horde_api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,33 @@ def test_problem_payload() -> None:
problem_payload = json.loads(json_from_api)

ImageGenerateJobPopResponse.model_validate(problem_payload)

json_from_api = """
{
"payload": {
"ddim_steps": 30,
"n_iter": 1,
"sampler_name": "k_euler_a",
"cfg_scale": 7.5,
"height": 512,
"width": 512,
"karras": false,
"tiling": false,
"hires_fix": false,
"image_is_control": false,
"return_control_map": false
},
"id": null,
"ids": [],
"skipped": {"max_pixels": 1},
"model": null,
"source_image": null,
"source_processing": "img2img",
"source_mask": null,
"r2_upload": null,
"r2_uploads": null
}"""

problem_payload = json.loads(json_from_api)

ImageGenerateJobPopResponse.model_validate(problem_payload)

0 comments on commit 6ee058b

Please sign in to comment.