Home · Quickstart · User Guide and Examples · Interfaces Index · Developers · About · Nipy

# nipype.utils.draw_gantt_chart module

Module to draw an html gantt chart from logfile produced by `nipype.utils.profiler.log_nodes_cb()`

nipype.utils.draw_gantt_chart.calculate_resource_timeseries(events, resource)

  Given as event dictionary, calculate the resources used as a timeseries

  Parameters:

    - events (dictionary) – a dictionary of event-based node dictionaries of the workflow execution statistics

    - resource (string) – the resource of interest to return the time-series of; e.g. ‘runtime_memory_gb’, ‘estimated_threads’, etc

  Returns:

    time_series – a pandas Series object that contains timestamps as the indices and the resource amount as values

  Return type:

    pandas Series

nipype.utils.draw_gantt_chart.create_event_dict(start_time, nodes_list)

  Function to generate a dictionary of event (start/finish) nodes from the nodes list

  Parameters:

    - start_time (datetime.datetime) – a datetime object of the pipeline start time

    - nodes_list (list) – a list of the node dictionaries that were run in the pipeline

  Returns:

    events – a dictionary where the key is the timedelta from the start of the pipeline execution to the value node it accompanies

  Return type:

    dictionary

nipype.utils.draw_gantt_chart.draw_lines(start, total_duration, minute_scale, scale)

  Function to draw the minute line markers and timestamps

  Parameters:

    - start (datetime.datetime obj) – start time for first minute line marker

    - total_duration (float) – total duration of the workflow execution (in seconds)

    - minute_scale (integer) – the scale, in minutes, at which to plot line markers for the gantt chart; for example, minute_scale=10 means there are lines drawn at every 10 minute interval from start to finish

    - scale (integer) – scale factor in pixel spacing between minute line markers

  Returns:

    result – the html-formatted string for producing the minutes-based time line markers

  Return type:

    string

nipype.utils.draw_gantt_chart.draw_nodes(start, nodes_list, cores, minute_scale, space_between_minutes, colors)

  Function to return the html-string of the node drawings for the gantt chart

  Parameters:

    - start (datetime.datetime obj) – start time for first node

    - nodes_list (list) – a list of the node dictionaries

    - cores (integer) – the number of cores given to the workflow via the ‘n_procs’ plugin arg

    - total_duration (float) – total duration of the workflow execution (in seconds)

    - minute_scale (integer) – the scale, in minutes, at which to plot line markers for the gantt chart; for example, minute_scale=10 means there are lines drawn at every 10 minute interval from start to finish

    - space_between_minutes (integer) – scale factor in pixel spacing between minute line markers

    - colors (list) – a list of colors to choose from when coloring the nodes in the gantt chart

  Returns:

    result – the html-formatted string for producing the minutes-based time line markers

  Return type:

    string

nipype.utils.draw_gantt_chart.draw_resource_bar(start_time, finish_time, time_series, space_between_minutes, minute_scale, color, left, resource)

nipype.utils.draw_gantt_chart.generate_gantt_chart(logfile, cores, minute_scale=10, space_between_minutes=50, colors=['#7070FF', '#4E4EB2', '#2D2D66', '#9B9BFF'])

  Generates a gantt chart in html showing the workflow execution based on a callback log file. This script was intended to be used with the MultiprocPlugin. The following code shows how to set up the workflow in order to generate the log file:

  Parameters:

    - logfile (string) – filepath to the callback log file to plot the gantt chart of

    - cores (integer) – the number of cores given to the workflow via the ‘n_procs’ plugin arg

    - minute_scale (integer (optional); default=10) – the scale, in minutes, at which to plot line markers for the gantt chart; for example, minute_scale=10 means there are lines drawn at every 10 minute interval from start to finish

    - space_between_minutes (integer (optional); default=50) – scale factor in pixel spacing between minute line markers

    - colors (list (optional)) – a list of colors to choose from when coloring the nodes in the gantt chart

  Returns:

    - None – the function does not return any value but writes out an html file in the same directory as the callback log path passed in

    - Usage

    - —–

    - # import logging

    - # import logging.handlers

    - # from nipype.utils.profiler import log_nodes_cb

    - # log_filename = ‘callback.log’

    - # logger = logging.getLogger(‘callback’)

    - # logger.setLevel(logging.DEBUG)

    - # handler = logging.FileHandler(log_filename)

    - # logger.addHandler(handler)

    - # #create workflow

    - # workflow = …

    - # workflow.run(plugin=’MultiProc’,

    - # plugin_args={‘n_procs’ (8, ‘memory’:12, ‘status_callback’: log_nodes_cb}))

    - # generate_gantt_chart(‘callback.log’, 8)

nipype.utils.draw_gantt_chart.log_to_dict(logfile)

  Function to extract log node dictionaries into a list of python dictionaries and return the list as well as the final node

  Parameters:

    logfile (string) – path to the json-formatted log file generated from a nipype workflow execution

  Returns:

    nodes_list – a list of python dictionaries containing the runtime info for each nipype node

  Return type:

    list