Skip to content

Commit 621c894

Browse files
committed
FIX: Convert timing values to datetimes from strings
* exclude nodes without timing information from Gantt chart * fall back on "id" or empty string if no "name" in node
1 parent 1ccee34 commit 621c894

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

nipype/utils/draw_gantt_chart.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def draw_nodes(start, nodes_list, cores, minute_scale, space_between_minutes, co
307307
"offset": offset,
308308
"scale_duration": scale_duration,
309309
"color": color,
310-
"node_name": node["name"],
310+
"node_name": node.get("name", node.get("id", "")),
311311
"node_dur": node["duration"] / 60.0,
312312
"node_start": node_start.strftime("%Y-%m-%d %H:%M:%S"),
313313
"node_finish": node_finish.strftime("%Y-%m-%d %H:%M:%S"),
@@ -527,6 +527,20 @@ def generate_gantt_chart(
527527
# Read in json-log to get list of node dicts
528528
nodes_list = log_to_dict(logfile)
529529

530+
# Only include nodes with timing information, and covert timestamps
531+
# from strings to datetimes
532+
nodes_list = [{
533+
k: datetime.datetime.strptime(
534+
i[k], "%Y-%m-%dT%H:%M:%S.%f"
535+
) if k in {"start", "finish"} else i[k] for k in i
536+
} for i in nodes_list if "start" in i and "finish" in i]
537+
538+
for node in nodes_list:
539+
if "duration" not in node:
540+
node["duration"] = (
541+
node["finish"] - node["start"]
542+
).total_seconds()
543+
530544
# Create the header of the report with useful information
531545
start_node = nodes_list[0]
532546
last_node = nodes_list[-1]

0 commit comments

Comments
 (0)