Skip to content

Commit 6a0480d

Browse files
committed
feat(server): make ComfyUI log level configurable
This commit introduces the `comfyui-log-level` and `comfyui-inference-log-level` arguments to the server, allowing users to adjust the log level and reduce excessive logging.
1 parent 76d820c commit 6a0480d

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

server/app.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ async def on_startup(app: web.Application):
287287
patch_loop_datagram(app["media_ports"])
288288

289289
app["pipeline"] = Pipeline(
290-
cwd=app["workspace"], disable_cuda_malloc=True, gpu_only=True
290+
cwd=app["workspace"],
291+
disable_cuda_malloc=True,
292+
gpu_only=True,
293+
comfyui_log_level=app.get("comfyui_log_level", None),
291294
)
292295
app["pcs"] = set()
293296
app["video_tracks"] = {}
@@ -328,6 +331,12 @@ async def on_shutdown(app: web.Application):
328331
action="store_true",
329332
help="Include stream ID as a label in Prometheus metrics.",
330333
)
334+
parser.add_argument(
335+
"--comfyui-log-level",
336+
default=None,
337+
choices=logging._nameToLevel.keys(),
338+
help="Override the ComfyUI client log level",
339+
)
331340
args = parser.parse_args()
332341

333342
logging.basicConfig(
@@ -377,4 +386,8 @@ def force_print(*args, **kwargs):
377386
print(*args, **kwargs, flush=True)
378387
sys.stdout.flush()
379388

389+
# Allow people to override the ComfyUI client log level.
390+
if args.comfyui_log_level:
391+
app["comfyui_log_level"] = args.comfyui_log_level
392+
380393
web.run_app(app, host=args.host, port=int(args.port), print=force_print)

server/pipeline.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@
1010

1111

1212
class Pipeline:
13-
def __init__(self, **kwargs):
14-
self.client = ComfyStreamClient(**kwargs, max_workers=5) # TODO: hardcoded max workers, should it be configurable?
13+
def __init__(self, comfyui_log_level: int = None, **kwargs):
14+
"""Initialize the pipeline with the given configuration.
15+
16+
Args:
17+
comfyui_log_level: Log level for the ComfyUI client. Defaults to None, using ComfyUI's global log level.
18+
to None, which means using the global ComfyUI log level.
19+
**kwargs: Additional arguments to pass to the ComfyStreamClient
20+
"""
21+
if comfyui_log_level is not None:
22+
kwargs["logging_level"] = comfyui_log_level
23+
24+
self.client = ComfyStreamClient(
25+
max_workers=5, **kwargs
26+
) # TODO: hardcoded max workers, should it be configurable?
1527

1628
self.video_incoming_frames = asyncio.Queue()
1729
self.audio_incoming_frames = asyncio.Queue()
@@ -109,4 +121,4 @@ async def get_nodes_info(self) -> Dict[str, Any]:
109121
return nodes_info
110122

111123
async def cleanup(self):
112-
await self.client.cleanup()
124+
await self.client.cleanup()

0 commit comments

Comments
 (0)