Skip to content

Commit

Permalink
Log graphs & metadata that take long to render
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Mar 6, 2019
1 parent 9ed34c6 commit 49a6be0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/macrogen/visualize.py
@@ -1,5 +1,6 @@
from typing import Sequence
from datetime import date
from datetime import date, timedelta
from time import perf_counter
from multiprocessing.pool import Pool
from pathlib import Path

Expand Down Expand Up @@ -173,12 +174,18 @@ def render_file(filename):
Renders the given dot file to an svg file using dot.
"""
graph = AGraph(filename=filename)
starttime = perf_counter()
try:
resultfn = filename[:-3] + 'svg'
graph.draw(resultfn, format='svg', prog='dot')
return resultfn
except:
logger.exception('Failed to render %s', filename)
finally:
duration = timedelta(seconds=perf_counter()-starttime)
if duration > timedelta(seconds=5):
logger.warning('Rendering %s with %d nodes and %d edges took %s',
filename, graph.number_of_nodes(), graph.number_of_edges(), duration)


def render_all():
Expand Down

0 comments on commit 49a6be0

Please sign in to comment.