3131from typing import Optional
3232from api_server .routes .internal .internal_routes import InternalRoutes
3333
34-
3534class BinaryEventTypes :
3635 PREVIEW_IMAGE = 1
3736 UNENCODED_PREVIEW_IMAGE = 2
@@ -42,6 +41,21 @@ async def send_socket_catch_exception(function, message):
4241 except (aiohttp .ClientError , aiohttp .ClientPayloadError , ConnectionResetError ) as err :
4342 logging .warning ("send error: {}" .format (err ))
4443
44+ def get_comfyui_version ():
45+ comfyui_version = "unknown"
46+ repo_path = os .path .dirname (os .path .realpath (__file__ ))
47+ try :
48+ import pygit2
49+ repo = pygit2 .Repository (repo_path )
50+ comfyui_version = repo .describe (describe_strategy = pygit2 .GIT_DESCRIBE_TAGS )
51+ except Exception :
52+ try :
53+ import subprocess
54+ comfyui_version = subprocess .check_output (["git" , "describe" , "--tags" ], cwd = repo_path ).decode ('utf-8' )
55+ except Exception as e :
56+ logging .warning (f"Failed to get ComfyUI version: { e } " )
57+ return comfyui_version .strip ()
58+
4559@web .middleware
4660async def cache_control (request : web .Request , handler ):
4761 response : web .Response = await handler (request )
@@ -401,16 +415,20 @@ async def view_metadata(request):
401415 return web .json_response (dt ["__metadata__" ])
402416
403417 @routes .get ("/system_stats" )
404- async def get_queue (request ):
418+ async def system_stats (request ):
405419 device = comfy .model_management .get_torch_device ()
406420 device_name = comfy .model_management .get_torch_device_name (device )
407421 vram_total , torch_vram_total = comfy .model_management .get_total_memory (device , torch_total_too = True )
408422 vram_free , torch_vram_free = comfy .model_management .get_free_memory (device , torch_free_too = True )
423+
409424 system_stats = {
410425 "system" : {
411426 "os" : os .name ,
427+ "comfyui_version" : get_comfyui_version (),
412428 "python_version" : sys .version ,
413- "embedded_python" : os .path .split (os .path .split (sys .executable )[0 ])[1 ] == "python_embeded"
429+ "pytorch_version" : comfy .model_management .torch_version ,
430+ "embedded_python" : os .path .split (os .path .split (sys .executable )[0 ])[1 ] == "python_embeded" ,
431+ "argv" : sys .argv
414432 },
415433 "devices" : [
416434 {
0 commit comments