@@ -269,7 +269,7 @@ class TestNormalizeHistoryItem:
269269 """Unit tests for normalize_history_item()"""
270270
271271 def test_completed_job (self ):
272- """Completed history item should have correct status."""
272+ """Completed history item should have correct status and times from messages ."""
273273 history_item = {
274274 'prompt' : (
275275 5 , # priority
@@ -278,54 +278,61 @@ def test_completed_job(self):
278278 {
279279 'create_time' : 1234567890000 ,
280280 'extra_pnginfo' : {'workflow' : {'id' : 'workflow-xyz' }}
281- }, # milliseconds
281+ },
282282 ['node1' ],
283283 ),
284- 'status' : {'status_str' : 'success' , 'completed' : True , 'messages' : []},
284+ 'status' : {
285+ 'status_str' : 'success' ,
286+ 'completed' : True ,
287+ 'messages' : [
288+ ('execution_start' , {'prompt_id' : 'prompt-456' , 'timestamp' : 1234567890500 }),
289+ ('execution_success' , {'prompt_id' : 'prompt-456' , 'timestamp' : 1234567893000 }),
290+ ]
291+ },
285292 'outputs' : {},
286- 'execution_duration' : 2.5 ,
287293 }
288294 job = normalize_history_item ('prompt-456' , history_item )
289295
290296 assert job ['id' ] == 'prompt-456'
291297 assert job ['status' ] == 'completed'
292298 assert job ['priority' ] == 5
293- assert job ['execution_start_time' ] == 1234567890000
294- assert job ['execution_end_time' ] == 1234567890000 + 2500 # +2.5 seconds in ms
299+ assert job ['execution_start_time' ] == 1234567890500
300+ assert job ['execution_end_time' ] == 1234567893000
295301 assert job ['workflow_id' ] == 'workflow-xyz'
296302
297303 def test_failed_job (self ):
298- """Failed history item should have failed status and message."""
299- error_detail = {
300- 'node_id' : '5' ,
301- 'node_type' : 'KSampler' ,
302- 'exception_message' : 'CUDA out of memory' ,
303- 'exception_type' : 'RuntimeError' ,
304- 'traceback' : ['Traceback...' , 'RuntimeError: CUDA out of memory' ],
305- }
304+ """Failed history item should have failed status and error from messages."""
306305 history_item = {
307306 'prompt' : (
308307 5 ,
309308 'prompt-789' ,
310309 {'nodes' : {}},
311- {'create_time' : 1234567890 },
310+ {'create_time' : 1234567890000 },
312311 ['node1' ],
313312 ),
314313 'status' : {
315314 'status_str' : 'error' ,
316315 'completed' : False ,
317316 'messages' : [
318- ('execution_error' , error_detail )
317+ ('execution_start' , {'prompt_id' : 'prompt-789' , 'timestamp' : 1234567890500 }),
318+ ('execution_error' , {
319+ 'prompt_id' : 'prompt-789' ,
320+ 'node_id' : '5' ,
321+ 'node_type' : 'KSampler' ,
322+ 'exception_message' : 'CUDA out of memory' ,
323+ 'exception_type' : 'RuntimeError' ,
324+ 'traceback' : ['Traceback...' , 'RuntimeError: CUDA out of memory' ],
325+ 'timestamp' : 1234567891000 ,
326+ })
319327 ]
320328 },
321329 'outputs' : {},
322- 'execution_duration' : 1.0 ,
323330 }
324331
325- # List view - includes execution_error
326332 job = normalize_history_item ('prompt-789' , history_item )
327333 assert job ['status' ] == 'failed'
328- assert job ['execution_error' ] == error_detail
334+ assert job ['execution_start_time' ] == 1234567890500
335+ assert job ['execution_end_time' ] == 1234567891000
329336 assert job ['execution_error' ]['node_id' ] == '5'
330337 assert job ['execution_error' ]['node_type' ] == 'KSampler'
331338 assert job ['execution_error' ]['exception_message' ] == 'CUDA out of memory'
@@ -342,7 +349,6 @@ def test_include_outputs(self):
342349 ),
343350 'status' : {'status_str' : 'success' , 'completed' : True , 'messages' : []},
344351 'outputs' : {'node1' : {'images' : [{'filename' : 'test.png' }]}},
345- 'execution_duration' : 2.5 ,
346352 }
347353 job = normalize_history_item ('prompt-123' , history_item , include_outputs = True )
348354
0 commit comments