bizyengine 1.2.82__py3-none-any.whl → 1.2.83__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bizyengine/bizyair_extras/third_party_api/trd_nodes_base.py +44 -2
- bizyengine/misc/utils.py +19 -0
- bizyengine/version.txt +1 -1
- {bizyengine-1.2.82.dist-info → bizyengine-1.2.83.dist-info}/METADATA +1 -1
- {bizyengine-1.2.82.dist-info → bizyengine-1.2.83.dist-info}/RECORD +7 -7
- {bizyengine-1.2.82.dist-info → bizyengine-1.2.83.dist-info}/WHEEL +1 -1
- {bizyengine-1.2.82.dist-info → bizyengine-1.2.83.dist-info}/top_level.txt +0 -0
|
@@ -3,6 +3,7 @@ import asyncio
|
|
|
3
3
|
import io
|
|
4
4
|
import json
|
|
5
5
|
import logging
|
|
6
|
+
import os
|
|
6
7
|
import time
|
|
7
8
|
from typing import List, Tuple
|
|
8
9
|
|
|
@@ -20,9 +21,15 @@ from bizyengine.core.common import client
|
|
|
20
21
|
from bizyengine.core.common.client import async_send_request, send_request
|
|
21
22
|
from bizyengine.core.common.env_var import BIZYAIR_X_SERVER
|
|
22
23
|
from bizyengine.core.nodes_base import PREFIX
|
|
24
|
+
from bizyengine.misc.utils import AsyncAtomicCounter
|
|
23
25
|
|
|
24
26
|
from ..utils.aliyun_oss import parse_upload_token, upload_file_without_sdk
|
|
25
27
|
|
|
28
|
+
_trd_api_counter = AsyncAtomicCounter(0)
|
|
29
|
+
# 常驻内存可以
|
|
30
|
+
_placeholder_img = None
|
|
31
|
+
_placeholder_video = None
|
|
32
|
+
|
|
26
33
|
|
|
27
34
|
class TrdBase(abc.ABC):
|
|
28
35
|
@abc.abstractmethod
|
|
@@ -52,9 +59,44 @@ class BizyAirTrdApiBaseNode(BizyAirMiscBaseNode, TrdBase):
|
|
|
52
59
|
prompt_id = extra_data["prompt_id"]
|
|
53
60
|
headers["X-BIZYAIR-PROMPT-ID"] = prompt_id
|
|
54
61
|
|
|
62
|
+
e = None
|
|
63
|
+
outputs = [[], [], []]
|
|
55
64
|
data, model = self.handle_inputs(headers, prompt_id, **kwargs)
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
try:
|
|
66
|
+
await _trd_api_counter.increment(1)
|
|
67
|
+
outputs = await self.create_task_and_wait_for_completion(
|
|
68
|
+
data, model, headers
|
|
69
|
+
)
|
|
70
|
+
except Exception as api_err:
|
|
71
|
+
e = api_err
|
|
72
|
+
finally:
|
|
73
|
+
await _trd_api_counter.increment(-1)
|
|
74
|
+
if e is not None:
|
|
75
|
+
# 还有未完成的其他并发
|
|
76
|
+
if await _trd_api_counter.value() > 0:
|
|
77
|
+
logging.error(
|
|
78
|
+
f"BizyAir task failed (silently because of other tasks executing in parallel), error: {str(e)}"
|
|
79
|
+
)
|
|
80
|
+
# return placeholders
|
|
81
|
+
dir = os.path.dirname(__file__)
|
|
82
|
+
global _placeholder_img, _placeholder_video
|
|
83
|
+
if _placeholder_img is None:
|
|
84
|
+
with open(os.path.join(dir, "placeholder.png"), "rb") as f:
|
|
85
|
+
image_content = f.read()
|
|
86
|
+
_placeholder_img = bytesio_to_image_tensor(
|
|
87
|
+
io.BytesIO(image_content)
|
|
88
|
+
)
|
|
89
|
+
if _placeholder_video is None:
|
|
90
|
+
with open(os.path.join(dir, "placeholder.mp4"), "rb") as f:
|
|
91
|
+
video_content = f.read()
|
|
92
|
+
_placeholder_video = VideoFromFile(
|
|
93
|
+
io.BytesIO(video_content)
|
|
94
|
+
)
|
|
95
|
+
outputs = [[_placeholder_video], [_placeholder_img], [str(e)]]
|
|
96
|
+
else:
|
|
97
|
+
# 无并发正常抛出
|
|
98
|
+
raise e
|
|
99
|
+
return self.handle_outputs(outputs)
|
|
58
100
|
|
|
59
101
|
async def create_task_and_wait_for_completion(
|
|
60
102
|
self, data, model, headers
|
bizyengine/misc/utils.py
CHANGED
|
@@ -459,3 +459,22 @@ def _cache_trd_models(type, request_api_key: str):
|
|
|
459
459
|
if len(models) == 0:
|
|
460
460
|
raise errno.NO_MODEL_FOUND
|
|
461
461
|
_TRD_MODELS_CACHE.set(type, models)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
class AsyncAtomicCounter(object):
|
|
465
|
+
"""An atomic, async counter"""
|
|
466
|
+
|
|
467
|
+
def __init__(self, initial=0):
|
|
468
|
+
self._value = initial
|
|
469
|
+
self._lock = asyncio.Lock()
|
|
470
|
+
|
|
471
|
+
async def increment(self, num=1):
|
|
472
|
+
"""Atomically increment the counter by num and return the new value"""
|
|
473
|
+
async with self._lock:
|
|
474
|
+
self._value += num
|
|
475
|
+
return self._value
|
|
476
|
+
|
|
477
|
+
async def value(self):
|
|
478
|
+
"""Get the current value (this read is also atomic due to the lock)"""
|
|
479
|
+
async with self._lock:
|
|
480
|
+
return self._value
|
bizyengine/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.83
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bizyengine
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.83
|
|
4
4
|
Summary: [a/BizyAir](https://github.com/siliconflow/BizyAir) Comfy Nodes that can run in any environment.
|
|
5
5
|
Author-email: SiliconFlow <yaochi@siliconflow.cn>
|
|
6
6
|
Project-URL: Repository, https://github.com/siliconflow/BizyAir
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
bizyengine/__init__.py,sha256=GP9V-JM07fz7uv_qTB43QEA2rKdrVJxi5I7LRnn_3ZQ,914
|
|
2
|
-
bizyengine/version.txt,sha256=
|
|
2
|
+
bizyengine/version.txt,sha256=eW3ubbBpwm8g4sWql3pfqnty4K5O8_wlYZNCAtMgIak,6
|
|
3
3
|
bizyengine/bizy_server/__init__.py,sha256=SP9oSblnPo4KQyh7yOGD26YCskFAcQHAZy04nQBNRIw,200
|
|
4
4
|
bizyengine/bizy_server/api_client.py,sha256=oe06P7l8t7lgkACbqN2UdS5R-IlZIINka6eWw8YyVv4,44451
|
|
5
5
|
bizyengine/bizy_server/errno.py,sha256=Qb-V0461LAYpsMMxgLggSZxlIPPaOhhV9k1TkMfqm_U,17494
|
|
@@ -57,7 +57,7 @@ bizyengine/bizyair_extras/third_party_api/nodes_veo3.py,sha256=LzZl-9iLMe5IzEAXY
|
|
|
57
57
|
bizyengine/bizyair_extras/third_party_api/nodes_vidu.py,sha256=-Eo2su0-t9qNPa5J4Qt3fx8xM9NjFHmgl19gMcTU7nM,10012
|
|
58
58
|
bizyengine/bizyair_extras/third_party_api/nodes_vlm.py,sha256=WF4QysWv3IJ1S-dxlwCzf5xazqOJxtlPyg4zDal70IA,4893
|
|
59
59
|
bizyengine/bizyair_extras/third_party_api/nodes_wan_api.py,sha256=GNc616NNsXcZYtojO2XTHwU3AFiprX6tFJ7qu3s2jgc,14508
|
|
60
|
-
bizyengine/bizyair_extras/third_party_api/trd_nodes_base.py,sha256=
|
|
60
|
+
bizyengine/bizyair_extras/third_party_api/trd_nodes_base.py,sha256=3ehpGi-2Jkbt4Dun1EnKCjHQZHw6-VWTO4_9D-yAuW8,10843
|
|
61
61
|
bizyengine/bizyair_extras/utils/aliyun_oss.py,sha256=H6wGZq1DqP7BHJ_frBJVvUVttgXprJprOnxytePIuos,3050
|
|
62
62
|
bizyengine/bizyair_extras/utils/audio.py,sha256=cCmX080jtxsHFa7mCgn13R6cyfqE-1Gq37ZnRJdZNU8,3183
|
|
63
63
|
bizyengine/bizybot/__init__.py,sha256=NINN_7QECKQwtAwKPBTrrSiAK6KbxaZCkIvJ-e1J1xk,262
|
|
@@ -104,8 +104,8 @@ bizyengine/misc/nodes_controlnet_union_sdxl.py,sha256=fYyu_XMY7mcX1Ad9x30q1tYB8m
|
|
|
104
104
|
bizyengine/misc/route_sam.py,sha256=-bMIR2QalfnszipGxSxvDAHGJa5gPSrjkYPb5baaRg4,1561
|
|
105
105
|
bizyengine/misc/segment_anything.py,sha256=wNKYwlYPMszfwj23524geFZJjZaG4eye65SGaUnh77I,8941
|
|
106
106
|
bizyengine/misc/supernode.py,sha256=STN9gaxfTSErH8OiHeZa47d8z-G9S0I7fXuJvHQOBFM,4532
|
|
107
|
-
bizyengine/misc/utils.py,sha256=
|
|
108
|
-
bizyengine-1.2.
|
|
109
|
-
bizyengine-1.2.
|
|
110
|
-
bizyengine-1.2.
|
|
111
|
-
bizyengine-1.2.
|
|
107
|
+
bizyengine/misc/utils.py,sha256=1XRC7WN_cKJ1ln6QVBKTQnfqzCepXF8AWlWJgiY_At4,15207
|
|
108
|
+
bizyengine-1.2.83.dist-info/METADATA,sha256=4H94G3pNkBtf8gT5NlpqyHPC8mC9A9rM6F-umEGQuCQ,735
|
|
109
|
+
bizyengine-1.2.83.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
110
|
+
bizyengine-1.2.83.dist-info/top_level.txt,sha256=2zapzqxX-we5cRyJkGf9bd5JinRtXp3-_uDI-xCAnc0,11
|
|
111
|
+
bizyengine-1.2.83.dist-info/RECORD,,
|
|
File without changes
|