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