diff --git a/comfy_execution/jobs.py b/comfy_execution/jobs.py index ac70fb1e4..d9e23ceed 100644 --- a/comfy_execution/jobs.py +++ b/comfy_execution/jobs.py @@ -50,7 +50,7 @@ def is_previewable(media_type, item): def normalize_queue_item(item, status): """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') extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {} workflow_id = extra_pnginfo.get('workflow', {}).get('id') @@ -58,8 +58,8 @@ def normalize_queue_item(item, status): return { 'id': prompt_id, 'status': status, + 'priority': priority, 'create_time': create_time, - 'error_message': None, 'execution_error': None, 'execution_start_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): """Convert history item dict to unified job dict.""" 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') extra_pnginfo = extra_data.get('extra_pnginfo', {}) or {} 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_count, preview_output = get_outputs_summary(outputs) - error_message = None execution_error = None if status == JobStatus.FAILED and status_info: 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': detail = entry[1] if isinstance(detail, dict): - error_message = str(detail.get('exception_message', '')) execution_error = detail break @@ -111,8 +109,8 @@ def normalize_history_item(prompt_id, history_item, include_outputs=False): job = { 'id': prompt_id, 'status': status, + 'priority': priority, 'create_time': create_time, - 'error_message': error_message, 'execution_error': execution_error, 'execution_start_time': execution_start_time, 'execution_end_time': execution_end_time, diff --git a/tests/execution/test_execution.py b/tests/execution/test_execution.py index eedc9e27a..d86e192d6 100644 --- a/tests/execution/test_execution.py +++ b/tests/execution/test_execution.py @@ -942,7 +942,7 @@ class TestExecution: assert "outputs_count" in job, "Job should have outputs_count" assert "preview_output" in job, "Job should have preview_output" 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( self, client: ComfyClient, builder: GraphBuilder diff --git a/tests/execution/test_jobs.py b/tests/execution/test_jobs.py index 30e64b1e7..2b63e1e4e 100644 --- a/tests/execution/test_jobs.py +++ b/tests/execution/test_jobs.py @@ -256,10 +256,11 @@ class TestNormalizeQueueItem: assert job['id'] == 'prompt-123' assert job['status'] == 'pending' + assert job['priority'] == 10 assert job['create_time'] == 1234567890 assert job['execution_start_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['workflow_id'] == 'workflow-abc' @@ -288,6 +289,7 @@ class TestNormalizeHistoryItem: assert job['id'] == 'prompt-456' assert job['status'] == 'completed' + assert job['priority'] == 5 assert job['execution_start_time'] == 1234567890000 assert job['execution_end_time'] == 1234567890000 + 2500 # +2.5 seconds in ms assert job['workflow_id'] == 'workflow-xyz' @@ -323,10 +325,10 @@ class TestNormalizeHistoryItem: # List view - includes execution_error job = normalize_history_item('prompt-789', history_item) assert job['status'] == 'failed' - assert job['error_message'] == 'CUDA out of memory' assert job['execution_error'] == error_detail assert job['execution_error']['node_id'] == '5' assert job['execution_error']['node_type'] == 'KSampler' + assert job['execution_error']['exception_message'] == 'CUDA out of memory' def test_include_outputs(self): """When include_outputs=True, should include full output data."""