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: check by value for KNOWN_UPSCALERS enum membership #159

Merged
merged 1 commit into from
Mar 9, 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
5 changes: 4 additions & 1 deletion horde_sdk/ai_horde_api/apimodels/generate/_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def has_upscaler(self) -> bool:
if len(self.payload.post_processing) == 0:
return False

return any(post_processing in KNOWN_UPSCALERS.__members__ for post_processing in self.payload.post_processing)
return any(
post_processing in KNOWN_UPSCALERS.__members__ or post_processing in KNOWN_UPSCALERS._value2member_map_
for post_processing in self.payload.post_processing
)

@property
def has_facefixer(self) -> bool:
Expand Down
7 changes: 7 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 @@ -436,6 +436,11 @@ def test_ImageGenerateJobPopResponse() -> None:
skipped=ImageGenerateJobPopSkippedStatus(),
)

assert all(
post_processor in KNOWN_UPSCALERS._value2member_map_
for post_processor in test_response.payload.post_processing
)

test_response = ImageGenerateJobPopResponse(
id=None,
ids=[JobID(root=UUID("00000000-0000-0000-0000-000000000000"))],
Expand All @@ -447,6 +452,8 @@ def test_ImageGenerateJobPopResponse() -> None:
skipped=ImageGenerateJobPopSkippedStatus(),
)

assert all(post_processor in KNOWN_UPSCALERS for post_processor in test_response.payload.post_processing)


def test_ImageGenerateJobPopResponse_hashability() -> None:
test_response_ids = ImageGenerateJobPopResponse(
Expand Down
Loading