Skip to content
Open
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
2 changes: 1 addition & 1 deletion civitai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def _poll_for_job_completion(self, token, interval=1, timeout=300):
logging.info(f"Job status: {last_response}")
for job in response.jobs:
if job.jobId not in completed_jobs:
if job.result and job.result.get("blobUrl"):
if job.result and [result.get("blobUrl") for result in job.result]:
completed_jobs[job.jobId] = {
"jobId": job.jobId,
"cost": job.cost,
Expand Down
14 changes: 7 additions & 7 deletions civitai/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class FromTextSchema(BaseModel):
quantity: Optional[int] = 1
properties: Optional[Dict[str, Any]] = None

@validator('params')
def params_validator(cls, v):
if 'width' in v and not (1 <= v['width'] <= 1024):
raise ValueError("Width must be between 1 and 1024")
if 'height' in v and not (1 <= v['height'] <= 1024):
raise ValueError("Height must be between 1 and 1024")
return v
# @validator('params')
# def params_validator(cls, v):
# if 'width' in v and not (1 <= v['width'] <= 1024):
# raise ValueError("Width must be between 1 and 1024")
# if 'height' in v and not (1 <= v['height'] <= 1024):
# raise ValueError("Height must be between 1 and 1024")
# return v

class Config:
# prevent any extra fields not defined in the schema (acts in .strict() in zod)
Expand Down
16 changes: 8 additions & 8 deletions civitai/services/async_Jobs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def get_v1consumerjobs(
)

if response.status_code not in [200, 202]:
raise HTTPException(response.status_code, f"Request to {path} failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f"Request to {path} failed with status code: {response.status_code} {response.text}")

return JobStatusCollection(**response.json()) if response.json() is not None else JobStatusCollection()

Expand Down Expand Up @@ -70,7 +70,7 @@ async def post_v1consumerjobs(
response = await client.request("post", httpx.URL(path), headers=headers, params=query_params, json=data if isinstance(data, dict) else data.dict())

if response.status_code not in [200, 202]:
raise HTTPException(response.status_code, f"Request failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f"Request failed with status code: {response.status_code} {response.text}")

return JobStatusCollection(**response.json()) if response.json() is not None else JobStatusCollection()

Expand All @@ -96,7 +96,7 @@ async def put_v1consumerjobs(
response = await client.request("put", httpx.URL(path), headers=headers, params=query_params, json=data.dict())

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return TaintJobsResult(**response.json()) if response.json() is not None else TaintJobsResult()

Expand Down Expand Up @@ -127,7 +127,7 @@ async def delete_v1consumerjobs(
)

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return None

Expand Down Expand Up @@ -158,7 +158,7 @@ async def get_v1consumerjobsjobId(
)

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return JobStatusCollection(**response.json()) if response.json() is not None else JobStatusCollection()

Expand All @@ -184,7 +184,7 @@ async def put_v1consumerjobsjobId(
response = await client.request("put", httpx.URL(path), headers=headers, params=query_params, json=data.dict())

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return None

Expand Down Expand Up @@ -215,7 +215,7 @@ async def delete_v1consumerjobsjobId(
)

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return None

Expand All @@ -241,6 +241,6 @@ async def post_v1consumerjobsquery(
response = await client.request("post", httpx.URL(path), headers=headers, params=query_params, json=data)

if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
raise HTTPException(response.status_code, f" failed with status code: {response.status_code} {response.text}")

return QueryJobsResult(**response.json()) if response.json() is not None else QueryJobsResult()
3 changes: 3 additions & 0 deletions tests/test_create_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import unittest
import json
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import civitai


Expand Down