Skip to content

Commit

Permalink
rendering limit
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Mar 1, 2019
1 parent 618a366 commit 43af2db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/macrogen/etc/default.yaml
Expand Up @@ -15,6 +15,7 @@ bibliography: https://raw.githubusercontent.com/faustedition/faust-gen-html/mast

## Limits
half_interval_correction: 182.5 # if we only have a start or end date, the other limit is max. this many days away
render_node_limit: 1000

## Other data
namespaces:
Expand Down
12 changes: 7 additions & 5 deletions src/macrogen/etc/logging.yaml
Expand Up @@ -16,11 +16,13 @@ root:
level: WARNING

loggers:
# graph:
macrogen.visualize:
level: INFO
# macrogen.graph:
# level: DEBUG
# uris:
# macrogen.uris:
# level: INFO
# datings:
# macrogen.datings:
# level: INFO
config:
level: DEBUG
macrogen.config:
level: INFO
4 changes: 2 additions & 2 deletions src/macrogen/report.py
Expand Up @@ -753,15 +753,15 @@ def report_index(graphs):

write_html(target / "index.php", report)
logger.info('Writing DAG ...')
write_dot(graphs.dag, target / 'dag-graph.dot', record=True)
write_dot(graphs.dag, target / 'dag-graph.dot')
write_html(target / 'dag.php', '<object type="image/svg+xml" data="dag-graph.svg" id="refgraph"/>',
graph_id='refgraph', head='Effektiver Gesamtgraph (ohne Konflikte)',
graph_options=dict(controlIconsEnabled=True, maxZoom=200))

logger.info('Creating transitive reduction ...')
tred_base = nx.MultiDiGraph(nx.transitive_reduction(graphs.dag))
tred = nx.edge_subgraph(graphs.dag, tred_base.edges)
write_dot(tred, target / 'tred-graph.dot', record=True)
write_dot(tred, target / 'tred-graph.dot')
write_html(target / 'tred.php', '<object type="image/svg+xml" data="tred-graph.svg" id="refgraph"/>',
graph_id='refgraph', head='Transitive Reduktion',
graph_options=dict(controlIconsEnabled=True, maxZoom=200))
Expand Down
9 changes: 7 additions & 2 deletions src/macrogen/visualize.py
Expand Up @@ -83,8 +83,13 @@ def write_dot(graph: nx.MultiDiGraph, target='base_graph.dot', style=None,
logger.info('Writing %s ...', target)
target_path = Path(target)
target_path.parent.mkdir(exist_ok=True, parents=True)
if record == 'auto':
record = len(graph.edges) < 1000
try:
if record == 'auto' and config.render_node_limit >= 0:
record = graph.number_of_nodes() < config.render_node_limit
if not record:
logger.info('%s is too large to be rendered automatically (%d nodes)', target, graph.number_of_nodes())
except Exception as e:
logger.warning('Auto edges limit configuration error: %s', e)

vis = graph.copy()
add_timeline_edges(vis)
Expand Down

0 comments on commit 43af2db

Please sign in to comment.