Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skipped logic #145

Merged
merged 2 commits into from
Feb 17, 2024
Merged
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
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)
Loading