@@ -103,8 +103,26 @@ def log_to_dict(logfile):
103
103
104
104
nodes_list = [json .loads (l ) for l in lines ]
105
105
106
+ def _convert_string_to_datetime (datestring ):
107
+ try :
108
+ datetime_object : datetime .datetime = datetime .datetime .strptime (
109
+ datestring , "%Y-%m-%dT%H:%M:%S.%f"
110
+ )
111
+ return datetime_object
112
+ except Exception as _ :
113
+ pass
114
+ return datestring
115
+
116
+ date_object_node_list : list = list ()
117
+ for n in nodes_list :
118
+ if "start" in n .keys ():
119
+ n ["start" ] = _convert_string_to_datetime (n ["start" ])
120
+ if "finish" in n .keys ():
121
+ n ["finish" ] = _convert_string_to_datetime (n ["finish" ])
122
+ date_object_node_list .append (n )
123
+
106
124
# Return list of nodes
107
- return nodes_list
125
+ return date_object_node_list
108
126
109
127
110
128
def calculate_resource_timeseries (events , resource ):
@@ -514,7 +532,11 @@ def generate_gantt_chart(
514
532
# Create the header of the report with useful information
515
533
start_node = nodes_list [0 ]
516
534
last_node = nodes_list [- 1 ]
517
- duration = (last_node ["finish" ] - start_node ["start" ]).total_seconds ()
535
+ duration : float = 0.0
536
+ if isinstance (start_node ["start" ], datetime .date ) and isinstance (
537
+ last_node ["finish" ], datetime .date
538
+ ):
539
+ duration = (last_node ["finish" ] - start_node ["start" ]).total_seconds ()
518
540
519
541
# Get events based dictionary of node run stats
520
542
events = create_event_dict (start_node ["start" ], nodes_list )
0 commit comments