mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-18 18:43:05 +08:00
send priority and remove error msg
This commit is contained in:
parent
a38aacf6e9
commit
1b673069fe
@ -50,7 +50,7 @@ def is_previewable(media_type, item):
|
|||||||
|
|
||||||
def normalize_queue_item(item, status):
|
def normalize_queue_item(item, status):
|
||||||
"""Convert queue item tuple to unified job dict."""
|
"""Convert queue item tuple to unified job dict."""
|
||||||
_, prompt_id, _, extra_data, _ = item[:5]
|
priority, prompt_id, _, extra_data, _ = item[:5]
|
||||||
create_time = extra_data.get('create_time')
|
create_time = extra_data.get('create_time')
|
||||||
extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {}
|
extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {}
|
||||||
workflow_id = extra_pnginfo.get('workflow', {}).get('id')
|
workflow_id = extra_pnginfo.get('workflow', {}).get('id')
|
||||||
@ -58,8 +58,8 @@ def normalize_queue_item(item, status):
|
|||||||
return {
|
return {
|
||||||
'id': prompt_id,
|
'id': prompt_id,
|
||||||
'status': status,
|
'status': status,
|
||||||
|
'priority': priority,
|
||||||
'create_time': create_time,
|
'create_time': create_time,
|
||||||
'error_message': None,
|
|
||||||
'execution_error': None,
|
'execution_error': None,
|
||||||
'execution_start_time': None,
|
'execution_start_time': None,
|
||||||
'execution_end_time': None,
|
'execution_end_time': None,
|
||||||
@ -72,7 +72,7 @@ def normalize_queue_item(item, status):
|
|||||||
def normalize_history_item(prompt_id, history_item, include_outputs=False):
|
def normalize_history_item(prompt_id, history_item, include_outputs=False):
|
||||||
"""Convert history item dict to unified job dict."""
|
"""Convert history item dict to unified job dict."""
|
||||||
prompt_tuple = history_item['prompt']
|
prompt_tuple = history_item['prompt']
|
||||||
_, _, prompt, extra_data, _ = prompt_tuple[:5]
|
priority, _, prompt, extra_data, _ = prompt_tuple[:5]
|
||||||
create_time = extra_data.get('create_time')
|
create_time = extra_data.get('create_time')
|
||||||
extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {}
|
extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {}
|
||||||
workflow_id = extra_pnginfo.get('workflow', {}).get('id')
|
workflow_id = extra_pnginfo.get('workflow', {}).get('id')
|
||||||
@ -89,7 +89,6 @@ def normalize_history_item(prompt_id, history_item, include_outputs=False):
|
|||||||
outputs = history_item.get('outputs', {})
|
outputs = history_item.get('outputs', {})
|
||||||
outputs_count, preview_output = get_outputs_summary(outputs)
|
outputs_count, preview_output = get_outputs_summary(outputs)
|
||||||
|
|
||||||
error_message = None
|
|
||||||
execution_error = None
|
execution_error = None
|
||||||
if status == JobStatus.FAILED and status_info:
|
if status == JobStatus.FAILED and status_info:
|
||||||
messages = status_info.get('messages', [])
|
messages = status_info.get('messages', [])
|
||||||
@ -97,7 +96,6 @@ def normalize_history_item(prompt_id, history_item, include_outputs=False):
|
|||||||
if isinstance(entry, (list, tuple)) and len(entry) >= 2 and entry[0] == 'execution_error':
|
if isinstance(entry, (list, tuple)) and len(entry) >= 2 and entry[0] == 'execution_error':
|
||||||
detail = entry[1]
|
detail = entry[1]
|
||||||
if isinstance(detail, dict):
|
if isinstance(detail, dict):
|
||||||
error_message = str(detail.get('exception_message', ''))
|
|
||||||
execution_error = detail
|
execution_error = detail
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -111,8 +109,8 @@ def normalize_history_item(prompt_id, history_item, include_outputs=False):
|
|||||||
job = {
|
job = {
|
||||||
'id': prompt_id,
|
'id': prompt_id,
|
||||||
'status': status,
|
'status': status,
|
||||||
|
'priority': priority,
|
||||||
'create_time': create_time,
|
'create_time': create_time,
|
||||||
'error_message': error_message,
|
|
||||||
'execution_error': execution_error,
|
'execution_error': execution_error,
|
||||||
'execution_start_time': execution_start_time,
|
'execution_start_time': execution_start_time,
|
||||||
'execution_end_time': execution_end_time,
|
'execution_end_time': execution_end_time,
|
||||||
|
|||||||
@ -942,7 +942,7 @@ class TestExecution:
|
|||||||
assert "outputs_count" in job, "Job should have outputs_count"
|
assert "outputs_count" in job, "Job should have outputs_count"
|
||||||
assert "preview_output" in job, "Job should have preview_output"
|
assert "preview_output" in job, "Job should have preview_output"
|
||||||
assert "workflow_id" in job, "Job should have workflow_id"
|
assert "workflow_id" in job, "Job should have workflow_id"
|
||||||
assert "error_message" in job, "Job should have error_message"
|
assert "execution_error" in job, "Job should have execution_error"
|
||||||
|
|
||||||
def test_jobs_api_preview_output_structure(
|
def test_jobs_api_preview_output_structure(
|
||||||
self, client: ComfyClient, builder: GraphBuilder
|
self, client: ComfyClient, builder: GraphBuilder
|
||||||
|
|||||||
@ -256,10 +256,11 @@ class TestNormalizeQueueItem:
|
|||||||
|
|
||||||
assert job['id'] == 'prompt-123'
|
assert job['id'] == 'prompt-123'
|
||||||
assert job['status'] == 'pending'
|
assert job['status'] == 'pending'
|
||||||
|
assert job['priority'] == 10
|
||||||
assert job['create_time'] == 1234567890
|
assert job['create_time'] == 1234567890
|
||||||
assert job['execution_start_time'] is None
|
assert job['execution_start_time'] is None
|
||||||
assert job['execution_end_time'] is None
|
assert job['execution_end_time'] is None
|
||||||
assert job['error_message'] is None
|
assert job['execution_error'] is None
|
||||||
assert job['outputs_count'] == 0
|
assert job['outputs_count'] == 0
|
||||||
assert job['workflow_id'] == 'workflow-abc'
|
assert job['workflow_id'] == 'workflow-abc'
|
||||||
|
|
||||||
@ -288,6 +289,7 @@ class TestNormalizeHistoryItem:
|
|||||||
|
|
||||||
assert job['id'] == 'prompt-456'
|
assert job['id'] == 'prompt-456'
|
||||||
assert job['status'] == 'completed'
|
assert job['status'] == 'completed'
|
||||||
|
assert job['priority'] == 5
|
||||||
assert job['execution_start_time'] == 1234567890000
|
assert job['execution_start_time'] == 1234567890000
|
||||||
assert job['execution_end_time'] == 1234567890000 + 2500 # +2.5 seconds in ms
|
assert job['execution_end_time'] == 1234567890000 + 2500 # +2.5 seconds in ms
|
||||||
assert job['workflow_id'] == 'workflow-xyz'
|
assert job['workflow_id'] == 'workflow-xyz'
|
||||||
@ -323,10 +325,10 @@ class TestNormalizeHistoryItem:
|
|||||||
# List view - includes execution_error
|
# List view - includes execution_error
|
||||||
job = normalize_history_item('prompt-789', history_item)
|
job = normalize_history_item('prompt-789', history_item)
|
||||||
assert job['status'] == 'failed'
|
assert job['status'] == 'failed'
|
||||||
assert job['error_message'] == 'CUDA out of memory'
|
|
||||||
assert job['execution_error'] == error_detail
|
assert job['execution_error'] == error_detail
|
||||||
assert job['execution_error']['node_id'] == '5'
|
assert job['execution_error']['node_id'] == '5'
|
||||||
assert job['execution_error']['node_type'] == 'KSampler'
|
assert job['execution_error']['node_type'] == 'KSampler'
|
||||||
|
assert job['execution_error']['exception_message'] == 'CUDA out of memory'
|
||||||
|
|
||||||
def test_include_outputs(self):
|
def test_include_outputs(self):
|
||||||
"""When include_outputs=True, should include full output data."""
|
"""When include_outputs=True, should include full output data."""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user