diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 3563eae..b22bbd9 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 2c1d440e-25e4-46e2-a435-ebd1f72a7373 management: - docChecksum: 90a1294d42e1fd57f405f6d16fa371c6 + docChecksum: 7a7ed6fb37d85f7f90cd0e561c98f203 docVersion: V2 - speakeasyVersion: 1.468.1 - generationVersion: 2.492.3 - releaseVersion: 0.6.2 - configChecksum: cde3aab15f4cc2df0a9349e7860df488 + speakeasyVersion: 1.468.9 + generationVersion: 2.493.21 + releaseVersion: 0.6.3 + configChecksum: 489397d9f122b1e9952a746f44940c07 repoURL: https://github.com/comfy-deploy/comfy-deploy-python.git installationURL: https://github.com/comfy-deploy/comfy-deploy-python.git published: true @@ -15,7 +15,7 @@ features: additionalDependencies: 1.0.0 callbacks: 2.0.0 constsAndDefaults: 1.0.5 - core: 5.10.0 + core: 5.10.2 defaultEnabledRetries: 0.2.0 deprecations: 3.0.2 devContainers: 3.0.0 @@ -44,7 +44,6 @@ generatedFiles: - .gitattributes - .python-version - .vscode/settings.json - - CONTRIBUTING.md - USAGE.md - docs/models/callbacks/createrundeploymentstreamrundeploymentstreampostrunupdaterequestbodywebhookpostresponse.md - docs/models/callbacks/createrunqueuerunqueuepostrunupdaterequestbodywebhookpostresponse.md @@ -378,7 +377,7 @@ examples: queue_workflow_run_run_workflow_queue_post: speakeasy-default-queue-workflow-run-run-workflow-queue-post: requestBody: - application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678"} + application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678", "workflow_api_json": {}} responses: "200": application/json: {"run_id": "03ec31b2-4d0d-4329-88ff-ac74003017b7"} @@ -387,7 +386,7 @@ examples: sync_workflow_run_run_workflow_sync_post: speakeasy-default-sync-workflow-run-run-workflow-sync-post: requestBody: - application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678"} + application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678", "workflow_api_json": {}} responses: "200": application/json: [{"id": "0897be30-8085-4c96-83b5-09c0142ddd3a", "run_id": "74537c27-c77e-45f3-8db2-d51ced44fce8", "data": {"key": [{"url": "https://excellent-someplace.com/", "type": "", "filename": "example.file"}], "key1": ["", {"url": "https://quixotic-pacemaker.name", "type": "", "filename": "example.file"}, {"url": "https://stupendous-reboot.com", "type": "", "filename": "example.file"}], "key2": [""]}, "node_meta": "", "created_at": "2025-06-15T03:39:15.085Z", "updated_at": "2023-01-07T17:33:50.101Z"}, {"id": "7b918394-ccd6-4006-bce6-e9d017d70eb9", "run_id": "65e87a7a-7857-4bfb-b41e-75104e9739c5", "data": {"key": []}, "node_meta": "", "created_at": "2023-08-28T07:34:17.021Z", "updated_at": "2024-05-07T07:06:17.977Z"}, {"id": "9f9cc0e7-be8b-46e8-8cb1-c6a768b8af61", "run_id": "a6bac807-9573-4ae1-9a78-99edf52381d0", "data": {"key": [{"url": "https://regal-pillbox.name/", "type": "", "filename": "example.file"}, ""], "key1": [{"url": "https://amused-completion.com/", "type": "", "filename": "example.file"}, {"url": "https://stingy-pulse.org/", "type": "", "filename": "example.file"}, {"url": "https://productive-populist.net/", "type": "", "filename": "example.file"}], "key2": [""]}, "node_meta": "", "created_at": "2024-09-02T10:46:05.380Z", "updated_at": "2025-02-12T08:26:26.046Z"}] @@ -396,7 +395,7 @@ examples: create_run_workflow_stream_run_workflow_stream_post: speakeasy-default-create-run-workflow-stream-run-workflow-stream-post: requestBody: - application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678"} + application/json: {"inputs": {"prompt": "A beautiful landscape", "seed": 42}, "webhook": "https://myapp.com/webhook", "workflow_id": "12345678-1234-5678-1234-567812345678", "workflow_api_json": {}} responses: "422": application/json: {} @@ -455,14 +454,14 @@ examples: application/json: {"workflow_version_id": "", "workflow_id": "", "machine_id": "", "environment": ""} responses: "200": - application/json: {"id": "7a621cf0-21cd-49cf-8540-3315211a509a", "user_id": "", "org_id": "", "workflow_version_id": "080a8e77-4c2b-4ecc-9376-91775e024985", "workflow_id": "13de0ee8-03d5-46a1-adf9-436bfd394947", "machine_id": "8bc19d4c-51e9-49df-9f42-acbeff61bc52", "share_slug": "", "description": "formula other gosh carouse", "environment": "staging", "created_at": "2024-02-24T22:31:50.589Z", "updated_at": "2024-09-18T22:12:00.266Z"} + application/json: {"id": "7a621cf0-21cd-49cf-8540-3315211a509a", "user_id": "", "org_id": "", "workflow_version_id": "080a8e77-4c2b-4ecc-9376-91775e024985", "workflow_id": "13de0ee8-03d5-46a1-adf9-436bfd394947", "machine_id": "8bc19d4c-51e9-49df-9f42-acbeff61bc52", "share_slug": "", "description": "formula other gosh carouse", "share_options": {}, "showcase_media": [{}], "environment": "staging", "created_at": "2024-02-24T22:31:50.589Z", "updated_at": "2024-09-18T22:12:00.266Z"} "422": application/json: {} get_deployments_deployments_get: speakeasy-default-get-deployments-deployments-get: responses: "200": - application/json: [{"id": "8a232aa0-b11b-48a0-8057-1e9e705d0e6e", "user_id": "", "org_id": "", "workflow_version_id": "1e276671-8d6d-4461-b2e0-aee1b9ddf121", "workflow_id": "c2a4c810-4fb4-451a-a70c-fc8fe07fbc60", "machine_id": "b960d561-1ff6-4573-be0a-62331ad7c07c", "share_slug": "", "description": "promptly expatiate dreamily of rosy", "showcase_media": [], "environment": "production", "created_at": "2025-03-21T06:52:57.825Z", "updated_at": "2025-07-20T01:34:08.268Z"}, {"id": "4753d0a1-7c47-48e3-829a-9ec97938e1a6", "user_id": "", "org_id": "", "workflow_version_id": "0f5fe368-082f-4a02-be08-74e78307648e", "workflow_id": "2ed7f303-9dec-46f4-a5d9-7b2c5d7f7bcf", "machine_id": "269af219-4d58-461b-83fe-5754c0c551a9", "share_slug": "", "description": "waft mortally toward by selfishly devise yet questioningly anenst", "environment": "staging", "created_at": "2024-08-14T18:41:19.055Z", "updated_at": "2024-03-01T04:00:01.219Z"}, {"id": "95ca433b-1104-4d1e-9fae-bad1494b3d27", "user_id": "", "org_id": "", "workflow_version_id": "b63f806d-94b8-443a-91ce-423bc77dd5bb", "workflow_id": "2fcfa6f3-f7b3-4d58-8ee6-1458f7304a0a", "machine_id": "715e54f6-42e8-46b7-9c60-873f569812ed", "share_slug": "", "description": "ripe solicit that willing gah", "showcase_media": [], "environment": "public-share", "created_at": "2024-10-02T09:00:05.612Z", "updated_at": "2025-04-03T09:40:26.403Z"}] + application/json: [{"id": "8a232aa0-b11b-48a0-8057-1e9e705d0e6e", "user_id": "", "org_id": "", "workflow_version_id": "1e276671-8d6d-4461-b2e0-aee1b9ddf121", "workflow_id": "c2a4c810-4fb4-451a-a70c-fc8fe07fbc60", "machine_id": "b960d561-1ff6-4573-be0a-62331ad7c07c", "share_slug": "", "description": "promptly expatiate dreamily of rosy", "share_options": {}, "showcase_media": [], "environment": "production", "created_at": "2025-03-21T06:52:57.825Z", "updated_at": "2025-07-20T01:34:08.268Z"}, {"id": "4753d0a1-7c47-48e3-829a-9ec97938e1a6", "user_id": "", "org_id": "", "workflow_version_id": "0f5fe368-082f-4a02-be08-74e78307648e", "workflow_id": "2ed7f303-9dec-46f4-a5d9-7b2c5d7f7bcf", "machine_id": "269af219-4d58-461b-83fe-5754c0c551a9", "share_slug": "", "description": "waft mortally toward by selfishly devise yet questioningly anenst", "share_options": {}, "showcase_media": [{}, {}, {}], "environment": "staging", "created_at": "2024-08-14T18:41:19.055Z", "updated_at": "2024-03-01T04:00:01.219Z"}, {"id": "95ca433b-1104-4d1e-9fae-bad1494b3d27", "user_id": "", "org_id": "", "workflow_version_id": "b63f806d-94b8-443a-91ce-423bc77dd5bb", "workflow_id": "2fcfa6f3-f7b3-4d58-8ee6-1458f7304a0a", "machine_id": "715e54f6-42e8-46b7-9c60-873f569812ed", "share_slug": "", "description": "ripe solicit that willing gah", "share_options": {}, "showcase_media": [], "environment": "public-share", "created_at": "2024-10-02T09:00:05.612Z", "updated_at": "2025-04-03T09:40:26.403Z"}] "422": application/json: {} upload_file_file_upload_post: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 64a3b23..2ccd6d7 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -16,7 +16,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.6.2 + version: 0.6.3 additionalDependencies: dev: {} main: {} @@ -26,6 +26,7 @@ python: clientServerStatusCodesAsErrors: true defaultErrorName: SDKError description: Python Client SDK Generated by Speakeasy + enableCustomCodeRegions: false enumFormat: enum fixFlags: responseRequiredSep2024: false diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 19c6007..8a843c1 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.468.1 +speakeasyVersion: 1.468.9 sources: comfydeploy-api: sourceNamespace: comfydeploy-api - sourceRevisionDigest: sha256:f9dc5cc0946a75e6462b5ba1a1d59b7f813179cfe669f6118f364ac34cd964d3 - sourceBlobDigest: sha256:ee2a461006d35edb1386cba134e3b2e817212649605f932e894e2c10c8b2547f + sourceRevisionDigest: sha256:467e23f8b7329f3f031f8f11eb90705b1a7b543e305f11475a97cf20d1cf32c8 + sourceBlobDigest: sha256:8442059b45a3f3a402b6ee31e4bbd83ac4199f8cfc758524ffc97fc3df5a400f tags: - latest - - speakeasy-sdk-regen-1736560726 + - speakeasy-sdk-regen-1736645562 - V2 targets: comfy-deploy: source: comfydeploy-api sourceNamespace: comfydeploy-api - sourceRevisionDigest: sha256:f9dc5cc0946a75e6462b5ba1a1d59b7f813179cfe669f6118f364ac34cd964d3 - sourceBlobDigest: sha256:ee2a461006d35edb1386cba134e3b2e817212649605f932e894e2c10c8b2547f + sourceRevisionDigest: sha256:467e23f8b7329f3f031f8f11eb90705b1a7b543e305f11475a97cf20d1cf32c8 + sourceBlobDigest: sha256:8442059b45a3f3a402b6ee31e4bbd83ac4199f8cfc758524ffc97fc3df5a400f codeSamplesNamespace: code-samples-python-comfy-deploy - codeSamplesRevisionDigest: sha256:52ce7fce4ff98ecc984debdf7cbfd4f42c6461794a9a973dd710a605cbc05b08 + codeSamplesRevisionDigest: sha256:6527150797b87444941356e0aec5a950c0568533f7f1733ab06a07791e96a062 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md new file mode 100644 index 0000000..70e8b36 --- /dev/null +++ b/README.md @@ -0,0 +1,555 @@ +# comfydeploy + +Developer-friendly & type-safe Python SDK specifically catered to leverage *comfydeploy* API. + +
+ + + + +
+ + +

+> [!IMPORTANT] +> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/comfydeploy/comfydeploy). Delete this section before > publishing to a package manager. + + +## Summary + +ComfyDeploy API: +### Overview + +Welcome to the ComfyDeploy API! + +To create a run thru the API, use the [queue run endpoint](#tag/run/POST/run/deployment/queue). + +Check out the [get run endpoint](#tag/run/GET/run/{run_id}), for getting the status and output of a run. + +### Authentication + +To authenticate your requests, include your API key in the `Authorization` header as a bearer token. Make sure to generate an API key in the [API Keys section of your ComfyDeploy account](https://www.comfydeploy.com/api-keys). + +### + + + +## Table of Contents + +* [comfydeploy](#comfydeploy) + * [SDK Installation](#sdk-installation) + * [IDE Support](#ide-support) + * [SDK Example Usage](#sdk-example-usage) + * [Authentication](#authentication) + * [Available Resources and Operations](#available-resources-and-operations) + * [Server-sent event streaming](#server-sent-event-streaming) + * [File uploads](#file-uploads) + * [Retries](#retries) + * [Error Handling](#error-handling) + * [Server Selection](#server-selection) + * [Custom HTTP Client](#custom-http-client) + * [Debugging](#debugging) +* [Development](#development) + * [Maturity](#maturity) + * [Contributions](#contributions) + + + + +## SDK Installation + +The SDK can be installed with either *pip* or *poetry* package managers. + +### PIP + +*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line. + +```bash +pip install comfydeploy +``` + +### Poetry + +*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies. + +```bash +poetry add comfydeploy +``` + + + +## IDE Support + +### PyCharm + +Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin. + +- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/) + + + +## SDK Example Usage + +### Example + +```python +# Synchronous Example +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) +``` + +
+ +The same SDK client can also be used to make asychronous requests by importing asyncio. +```python +# Asynchronous Example +import asyncio +from comfydeploy import ComfyDeploy + +async def main(): + async with ComfyDeploy( + bearer="", + ) as comfy_deploy: + + res = await comfy_deploy.run.get_async(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +asyncio.run(main()) +``` + + + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security scheme globally: + +| Name | Type | Scheme | +| -------- | ---- | ----------- | +| `bearer` | http | HTTP Bearer | + +To authenticate with the API the `bearer` parameter must be set when initializing the SDK client instance. For example: +```python +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +``` + + + +## Available Resources and Operations + +
+Available methods + + +### [deployments](docs/sdks/deployments/README.md) + +* [create](docs/sdks/deployments/README.md#create) - Create Deployment +* [list](docs/sdks/deployments/README.md#list) - Get Deployments + +### [file](docs/sdks/file/README.md) + +* [upload](docs/sdks/file/README.md#upload) - Upload File +* [create_folder_assets_folder_post](docs/sdks/file/README.md#create_folder_assets_folder_post) - Create Folder +* [list_assets_assets_get](docs/sdks/file/README.md#list_assets_assets_get) - List Assets +* [delete_asset_assets_asset_id_delete](docs/sdks/file/README.md#delete_asset_assets_asset_id_delete) - Delete Asset +* [get_asset_assets_asset_id_get](docs/sdks/file/README.md#get_asset_assets_asset_id_get) - Get Asset +* [upload_asset_file_assets_upload_post](docs/sdks/file/README.md#upload_asset_file_assets_upload_post) - Upload Asset File + +### [models](docs/sdks/models/README.md) + +* [public_models_models_get](docs/sdks/models/README.md#public_models_models_get) - Public Models + +### [run](docs/sdks/run/README.md) + +* [get](docs/sdks/run/README.md#get) - Get Run +* [~~queue~~](docs/sdks/run/README.md#queue) - Queue a workflow :warning: **Deprecated** +* [~~sync~~](docs/sdks/run/README.md#sync) - Run a workflow in sync :warning: **Deprecated** +* [~~stream~~](docs/sdks/run/README.md#stream) - Run a workflow in stream :warning: **Deprecated** +* [cancel_run_run_run_id_cancel_post](docs/sdks/run/README.md#cancel_run_run_run_id_cancel_post) - Cancel Run + +#### [run.deployment](docs/sdks/deployment/README.md) + +* [queue](docs/sdks/deployment/README.md#queue) - Deployment - Queue +* [sync](docs/sdks/deployment/README.md#sync) - Deployment - Sync +* [stream](docs/sdks/deployment/README.md#stream) - Deployment - Stream + +#### [run.workflow](docs/sdks/workflow/README.md) + +* [queue](docs/sdks/workflow/README.md#queue) - Workflow - Queue +* [sync](docs/sdks/workflow/README.md#sync) - Workflow - Sync +* [stream](docs/sdks/workflow/README.md#stream) - Workflow - Stream + +### [search](docs/sdks/search/README.md) + +* [search_search_model_get](docs/sdks/search/README.md#search_search_model_get) - Search + +### [session](docs/sdks/session/README.md) + +* [get](docs/sdks/session/README.md#get) - Get Session +* [cancel](docs/sdks/session/README.md#cancel) - Delete Session +* [list](docs/sdks/session/README.md#list) - Get Machine Sessions +* [increase_timeout_session_increase_timeout_post](docs/sdks/session/README.md#increase_timeout_session_increase_timeout_post) - Increase Timeout +* [create](docs/sdks/session/README.md#create) - Create Session + +
+ + + +## Server-sent event streaming + +[Server-sent events][mdn-sse] are used to stream content from certain +operations. These operations will expose the stream as [Generator][generator] that +can be consumed using a simple `for` loop. The loop will +terminate when the server no longer has any events to send and closes the +underlying connection. + +The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the +underlying connection when the context is exited. + +```python +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.deployment.stream(request={ + "deployment_id": "15e79589-12c9-453c-a41a-348fdd7de957", + "inputs": { + "prompt": "A beautiful landscape", + "seed": 42, + }, + "webhook": "https://myapp.com/webhook", + }) + + assert res.run_stream is not None + + with res.run_stream as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) + +``` + +[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events +[generator]: https://book.pythontips.com/en/latest/generators.html +[context-manager]: https://book.pythontips.com/en/latest/context_managers.html + + + +## File uploads + +Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request. + +> [!TIP] +> +> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files. +> + +```python +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + + res = comfy_deploy.file.upload(request={ + "file": { + "file_name": "example.file", + "content": open("example.file", "rb"), + }, + }) + + assert res.file_upload_response is not None + + # Handle response + print(res.file_upload_response) + +``` + + + +## Retries + +Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. + +To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call: +```python +from comfydeploy import ComfyDeploy +from comfydeploy.utils import BackoffStrategy, RetryConfig + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc", + RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False)) + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +``` + +If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK: +```python +from comfydeploy import ComfyDeploy +from comfydeploy.utils import BackoffStrategy, RetryConfig + +with ComfyDeploy( + retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False), + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +``` + + + +## Error Handling + +Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception. + +By default, an API error will raise a errors.SDKError exception, which has the following properties: + +| Property | Type | Description | +|-----------------|------------------|-----------------------| +| `.status_code` | *int* | The HTTP status code | +| `.message` | *str* | The error message | +| `.raw_response` | *httpx.Response* | The raw HTTP response | +| `.body` | *str* | The response content | + +When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `get_async` method may raise the following exceptions: + +| Error Type | Status Code | Content Type | +| -------------------------- | ----------- | ---------------- | +| errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | + +### Example + +```python +from comfydeploy import ComfyDeploy +from comfydeploy.models import errors + +with ComfyDeploy( + bearer="", +) as comfy_deploy: + res = None + try: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + + except errors.HTTPValidationError as e: + # handle e.data: errors.HTTPValidationErrorData + raise(e) + except errors.SDKError as e: + # handle exception + raise(e) +``` + + + +## Server Selection + +### Select Server by Index + +You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: + +| # | Server | +| --- | ----------------------------------------- | +| 0 | `https://api.comfydeploy.com/api` | +| 1 | `https://staging.api.comfydeploy.com/api` | +| 2 | `http://localhost:3011/api` | + +#### Example + +```python +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + server_idx=2, + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +``` + +### Override Server URL Per-Client + +The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: +```python +from comfydeploy import ComfyDeploy + +with ComfyDeploy( + server_url="https://api.comfydeploy.com/api", + bearer="", +) as comfy_deploy: + + res = comfy_deploy.run.get(run_id="b888f774-3e7c-4135-a18c-6b985523c4bc") + + assert res.workflow_run_model is not None + + # Handle response + print(res.workflow_run_model) + +``` + + + +## Custom HTTP Client + +The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance. +Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls. +This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly. + +For example, you could specify a header for every request that this sdk makes as follows: +```python +from comfydeploy import ComfyDeploy +import httpx + +http_client = httpx.Client(headers={"x-custom-header": "someValue"}) +s = ComfyDeploy(client=http_client) +``` + +or you could wrap the client with your own custom logic: +```python +from comfydeploy import ComfyDeploy +from comfydeploy.httpclient import AsyncHttpClient +import httpx + +class CustomClient(AsyncHttpClient): + client: AsyncHttpClient + + def __init__(self, client: AsyncHttpClient): + self.client = client + + async def send( + self, + request: httpx.Request, + *, + stream: bool = False, + auth: Union[ + httpx._types.AuthTypes, httpx._client.UseClientDefault, None + ] = httpx.USE_CLIENT_DEFAULT, + follow_redirects: Union[ + bool, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + ) -> httpx.Response: + request.headers["Client-Level-Header"] = "added by client" + + return await self.client.send( + request, stream=stream, auth=auth, follow_redirects=follow_redirects + ) + + def build_request( + self, + method: str, + url: httpx._types.URLTypes, + *, + content: Optional[httpx._types.RequestContent] = None, + data: Optional[httpx._types.RequestData] = None, + files: Optional[httpx._types.RequestFiles] = None, + json: Optional[Any] = None, + params: Optional[httpx._types.QueryParamTypes] = None, + headers: Optional[httpx._types.HeaderTypes] = None, + cookies: Optional[httpx._types.CookieTypes] = None, + timeout: Union[ + httpx._types.TimeoutTypes, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + extensions: Optional[httpx._types.RequestExtensions] = None, + ) -> httpx.Request: + return self.client.build_request( + method, + url, + content=content, + data=data, + files=files, + json=json, + params=params, + headers=headers, + cookies=cookies, + timeout=timeout, + extensions=extensions, + ) + +s = ComfyDeploy(async_client=CustomClient(httpx.AsyncClient())) +``` + + + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass your own logger class directly into your SDK. +```python +from comfydeploy import ComfyDeploy +import logging + +logging.basicConfig(level=logging.DEBUG) +s = ComfyDeploy(debug_logger=logging.getLogger("comfydeploy")) +``` + + + + +# Development + +## Maturity + +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally +looking for the latest version. + +## Contributions + +While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. +We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. + +### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=comfydeploy&utm_campaign=python) diff --git a/RELEASES.md b/RELEASES.md index f3f7c9b..c30ea7b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -168,4 +168,14 @@ Based on: ### Generated - [python v0.6.2] . ### Releases -- [PyPI v0.6.2] https://pypi.org/project/comfydeploy/0.6.2 - . \ No newline at end of file +- [PyPI v0.6.2] https://pypi.org/project/comfydeploy/0.6.2 - . + +## 2025-01-17 00:11:36 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.468.9 (2.493.21) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.6.3] . +### Releases +- [PyPI v0.6.3] https://pypi.org/project/comfydeploy/0.6.3 - . \ No newline at end of file diff --git a/docs/models/components/apiroutestypesmachinegpu2.md b/docs/models/components/apiroutestypesmachinegpu2.md index b780659..f9ae5ee 100644 --- a/docs/models/components/apiroutestypesmachinegpu2.md +++ b/docs/models/components/apiroutestypesmachinegpu2.md @@ -9,6 +9,7 @@ | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/docs/models/components/gpu.md b/docs/models/components/gpu.md index b1214a4..0bd9f60 100644 --- a/docs/models/components/gpu.md +++ b/docs/models/components/gpu.md @@ -10,6 +10,7 @@ The GPU to override the machine's default GPU | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/docs/models/components/machinegpuoutput.md b/docs/models/components/machinegpuoutput.md index 3353798..f506228 100644 --- a/docs/models/components/machinegpuoutput.md +++ b/docs/models/components/machinegpuoutput.md @@ -9,6 +9,7 @@ | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/docs/models/components/modelrunrequestgpu.md b/docs/models/components/modelrunrequestgpu.md index fdfa60a..52e6a68 100644 --- a/docs/models/components/modelrunrequestgpu.md +++ b/docs/models/components/modelrunrequestgpu.md @@ -10,6 +10,7 @@ The GPU to override the machine's default GPU | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/docs/models/components/workflowrunrequestgpu.md b/docs/models/components/workflowrunrequestgpu.md index 040cec6..00fe920 100644 --- a/docs/models/components/workflowrunrequestgpu.md +++ b/docs/models/components/workflowrunrequestgpu.md @@ -10,6 +10,7 @@ The GPU to override the machine's default GPU | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/docs/models/components/workflowrunversionrequestgpu.md b/docs/models/components/workflowrunversionrequestgpu.md index bc2b3ee..407daa4 100644 --- a/docs/models/components/workflowrunversionrequestgpu.md +++ b/docs/models/components/workflowrunversionrequestgpu.md @@ -10,6 +10,7 @@ The GPU to override the machine's default GPU | `T4` | T4 | | `L4` | L4 | | `A10_G` | A10G | +| `L40_S` | L40S | | `A100` | A100 | | `A100_80_GB` | A100-80GB | | `H100` | H100 | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6eebf09..b5daa1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "comfydeploy" -version = "0.6.2" +version = "0.6.3" description = "Python Client SDK Generated by Speakeasy" authors = [{ name = "Speakeasy" },] readme = "README-PYPI.md" diff --git a/src/comfydeploy/_version.py b/src/comfydeploy/_version.py index 77677f4..71a2a9d 100644 --- a/src/comfydeploy/_version.py +++ b/src/comfydeploy/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "comfydeploy" -__version__: str = "0.6.2" +__version__: str = "0.6.3" __openapi_doc_version__: str = "V2" -__gen_version__: str = "2.492.3" -__user_agent__: str = "speakeasy-sdk/python 0.6.2 2.492.3 V2 comfydeploy" +__gen_version__: str = "2.493.21" +__user_agent__: str = "speakeasy-sdk/python 0.6.3 2.493.21 V2 comfydeploy" try: if __package__ is not None: diff --git a/src/comfydeploy/deployment.py b/src/comfydeploy/deployment.py index e1a6830..442be7d 100644 --- a/src/comfydeploy/deployment.py +++ b/src/comfydeploy/deployment.py @@ -92,7 +92,12 @@ def queue( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -189,7 +194,12 @@ async def queue_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -286,7 +296,12 @@ def sync( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -383,7 +398,12 @@ async def sync_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -483,7 +503,12 @@ def stream( http_res_text = utils.stream_to_text(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -583,7 +608,12 @@ async def stream_async( http_res_text = await utils.stream_to_text_async(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/deployments.py b/src/comfydeploy/deployments.py index 2d88458..c322b14 100644 --- a/src/comfydeploy/deployments.py +++ b/src/comfydeploy/deployments.py @@ -89,7 +89,12 @@ def create( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -184,7 +189,12 @@ async def create_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -274,7 +284,12 @@ def list( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -364,7 +379,12 @@ async def list_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/file.py b/src/comfydeploy/file.py index 865163c..e8c27f0 100644 --- a/src/comfydeploy/file.py +++ b/src/comfydeploy/file.py @@ -94,7 +94,12 @@ def upload( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -194,7 +199,12 @@ async def upload_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -289,7 +299,12 @@ def create_folder_assets_folder_post( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -384,7 +399,12 @@ async def create_folder_assets_folder_post_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -474,7 +494,12 @@ def list_assets_assets_get( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -564,7 +589,12 @@ async def list_assets_assets_get_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -652,7 +682,12 @@ def delete_asset_assets_asset_id_delete( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -740,7 +775,12 @@ async def delete_asset_assets_asset_id_delete_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -830,7 +870,12 @@ def get_asset_assets_asset_id_get( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -920,7 +965,12 @@ async def get_asset_assets_asset_id_get_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1026,7 +1076,12 @@ def upload_asset_file_assets_upload_post( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1132,7 +1187,12 @@ async def upload_asset_file_assets_upload_post_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/models/callbacks/__init__.py b/src/comfydeploy/models/callbacks/__init__.py index f352063..19d13da 100644 --- a/src/comfydeploy/models/callbacks/__init__.py +++ b/src/comfydeploy/models/callbacks/__init__.py @@ -21,6 +21,7 @@ CreateRunWorkflowStreamRunWorkflowStreamPostRunUpdateRequestBodyWebhookPostResponseTypedDict, ) + __all__ = [ "CreateRunDeploymentStreamRunDeploymentStreamPostRunUpdateRequestBodyWebhookPostResponse", "CreateRunDeploymentStreamRunDeploymentStreamPostRunUpdateRequestBodyWebhookPostResponseTypedDict", diff --git a/src/comfydeploy/models/components/__init__.py b/src/comfydeploy/models/components/__init__.py index b3b136d..55c4674 100644 --- a/src/comfydeploy/models/components/__init__.py +++ b/src/comfydeploy/models/components/__init__.py @@ -129,6 +129,7 @@ from .workflowwithname import WorkflowWithName, WorkflowWithNameTypedDict from .workspacegpu import WorkspaceGPU + __all__ = [ "APIRoutesTypesMachineGPU2", "AssetResponse", diff --git a/src/comfydeploy/models/components/api_routes_types_machinegpu_2.py b/src/comfydeploy/models/components/api_routes_types_machinegpu_2.py index 7d5cac1..32f11bb 100644 --- a/src/comfydeploy/models/components/api_routes_types_machinegpu_2.py +++ b/src/comfydeploy/models/components/api_routes_types_machinegpu_2.py @@ -9,6 +9,7 @@ class APIRoutesTypesMachineGPU2(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/components/deploymentrunrequest.py b/src/comfydeploy/models/components/deploymentrunrequest.py index bce8d72..65e03b4 100644 --- a/src/comfydeploy/models/components/deploymentrunrequest.py +++ b/src/comfydeploy/models/components/deploymentrunrequest.py @@ -21,6 +21,7 @@ class Gpu(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/components/machinegpu_output.py b/src/comfydeploy/models/components/machinegpu_output.py index e4ca0f7..c87f643 100644 --- a/src/comfydeploy/models/components/machinegpu_output.py +++ b/src/comfydeploy/models/components/machinegpu_output.py @@ -9,6 +9,7 @@ class MachineGPUOutput(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/components/modelrunrequest.py b/src/comfydeploy/models/components/modelrunrequest.py index 176673e..173e480 100644 --- a/src/comfydeploy/models/components/modelrunrequest.py +++ b/src/comfydeploy/models/components/modelrunrequest.py @@ -23,6 +23,7 @@ class ModelRunRequestGpu(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/components/workflowrunrequest.py b/src/comfydeploy/models/components/workflowrunrequest.py index fbe8aa1..59d58bb 100644 --- a/src/comfydeploy/models/components/workflowrunrequest.py +++ b/src/comfydeploy/models/components/workflowrunrequest.py @@ -23,6 +23,7 @@ class WorkflowRunRequestGpu(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/components/workflowrunversionrequest.py b/src/comfydeploy/models/components/workflowrunversionrequest.py index e905575..500aaef 100644 --- a/src/comfydeploy/models/components/workflowrunversionrequest.py +++ b/src/comfydeploy/models/components/workflowrunversionrequest.py @@ -30,6 +30,7 @@ class WorkflowRunVersionRequestGpu(str, Enum): T4 = "T4" L4 = "L4" A10_G = "A10G" + L40_S = "L40S" A100 = "A100" A100_80_GB = "A100-80GB" H100 = "H100" diff --git a/src/comfydeploy/models/errors/__init__.py b/src/comfydeploy/models/errors/__init__.py index 97f412f..611acae 100644 --- a/src/comfydeploy/models/errors/__init__.py +++ b/src/comfydeploy/models/errors/__init__.py @@ -3,4 +3,5 @@ from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData from .sdkerror import SDKError + __all__ = ["HTTPValidationError", "HTTPValidationErrorData", "SDKError"] diff --git a/src/comfydeploy/models/operations/__init__.py b/src/comfydeploy/models/operations/__init__.py index 342e41f..620664d 100644 --- a/src/comfydeploy/models/operations/__init__.py +++ b/src/comfydeploy/models/operations/__init__.py @@ -133,6 +133,7 @@ UploadFileFileUploadPostResponseTypedDict, ) + __all__ = [ "CancelRunRunRunIDCancelPostRequest", "CancelRunRunRunIDCancelPostRequestTypedDict", diff --git a/src/comfydeploy/models/webhooks/__init__.py b/src/comfydeploy/models/webhooks/__init__.py index f266a76..065c657 100644 --- a/src/comfydeploy/models/webhooks/__init__.py +++ b/src/comfydeploy/models/webhooks/__init__.py @@ -5,6 +5,7 @@ RunUpdateRequestBodyWebhookPostResponseTypedDict, ) + __all__ = [ "RunUpdateRequestBodyWebhookPostResponse", "RunUpdateRequestBodyWebhookPostResponseTypedDict", diff --git a/src/comfydeploy/models_.py b/src/comfydeploy/models_.py index 4206713..0675633 100644 --- a/src/comfydeploy/models_.py +++ b/src/comfydeploy/models_.py @@ -75,7 +75,12 @@ def public_models_models_get( ), http_meta=components.HTTPMetadata(request=req, response=http_res), ) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -156,7 +161,12 @@ async def public_models_models_get_async( ), http_meta=components.HTTPMetadata(request=req, response=http_res), ) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/run.py b/src/comfydeploy/run.py index 16978a9..b3c1809 100644 --- a/src/comfydeploy/run.py +++ b/src/comfydeploy/run.py @@ -101,7 +101,12 @@ def get( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -191,7 +196,12 @@ async def get_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -294,7 +304,12 @@ def queue( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -397,7 +412,12 @@ async def queue_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -498,7 +518,12 @@ def sync( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -599,7 +624,12 @@ async def sync_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -709,7 +739,12 @@ def stream( http_res_text = utils.stream_to_text(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -819,7 +854,12 @@ async def stream_async( http_res_text = await utils.stream_to_text_async(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -921,7 +961,12 @@ def cancel_run_run_run_id_cancel_post( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1023,7 +1068,12 @@ async def cancel_run_run_run_id_cancel_post_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/sdk.py b/src/comfydeploy/sdk.py index 01cc43b..59c83d0 100644 --- a/src/comfydeploy/sdk.py +++ b/src/comfydeploy/sdk.py @@ -87,7 +87,8 @@ def __init__( security: Any = None if callable(bearer): - security = lambda: components.Security(bearer=bearer()) # pylint: disable=unnecessary-lambda-assignment + # pylint: disable=unnecessary-lambda-assignment + security = lambda: components.Security(bearer=bearer()) else: security = components.Security(bearer=bearer) diff --git a/src/comfydeploy/search.py b/src/comfydeploy/search.py index cc630f8..829101d 100644 --- a/src/comfydeploy/search.py +++ b/src/comfydeploy/search.py @@ -87,7 +87,12 @@ def search_search_model_get( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -180,7 +185,12 @@ async def search_search_model_get_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/session.py b/src/comfydeploy/session.py index 44c6bd5..fb24f5d 100644 --- a/src/comfydeploy/session.py +++ b/src/comfydeploy/session.py @@ -84,7 +84,12 @@ def get( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -174,7 +179,12 @@ async def get_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -264,7 +274,12 @@ def cancel( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -354,7 +369,12 @@ async def cancel_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -444,7 +464,12 @@ def list( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -534,7 +559,12 @@ async def list_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -627,7 +657,12 @@ def increase_timeout_session_increase_timeout_post( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -720,7 +755,12 @@ async def increase_timeout_session_increase_timeout_post_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -815,7 +855,12 @@ def create( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -910,7 +955,12 @@ async def create_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/comfydeploy/workflow.py b/src/comfydeploy/workflow.py index b30ab96..6af35db 100644 --- a/src/comfydeploy/workflow.py +++ b/src/comfydeploy/workflow.py @@ -92,7 +92,12 @@ def queue( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -189,7 +194,12 @@ async def queue_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -286,7 +296,12 @@ def sync( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -383,7 +398,12 @@ async def sync_async( if utils.match_response(http_res, "422", "application/json"): data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -483,7 +503,12 @@ def stream( http_res_text = utils.stream_to_text(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -583,7 +608,12 @@ async def stream_async( http_res_text = await utils.stream_to_text_async(http_res) data = utils.unmarshal_json(http_res_text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res