diff --git a/civitai/__init__.py b/civitai/__init__.py index 7e8acd9..8fc12fa 100644 --- a/civitai/__init__.py +++ b/civitai/__init__.py @@ -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, diff --git a/civitai/schemas/__init__.py b/civitai/schemas/__init__.py index 0b037db..b564baa 100644 --- a/civitai/schemas/__init__.py +++ b/civitai/schemas/__init__.py @@ -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) diff --git a/civitai/services/async_Jobs_service.py b/civitai/services/async_Jobs_service.py index a46f63e..410693a 100644 --- a/civitai/services/async_Jobs_service.py +++ b/civitai/services/async_Jobs_service.py @@ -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() @@ -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() @@ -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() @@ -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 @@ -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() @@ -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 @@ -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 @@ -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() diff --git a/tests/test_create_image.py b/tests/test_create_image.py index 0d2dd5a..1098134 100644 --- a/tests/test_create_image.py +++ b/tests/test_create_image.py @@ -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