Skip to content

Commit

Permalink
Allow to run reports independently from analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Sep 29, 2019
1 parent 719550c commit d0470bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/macrogen/etc/default.yaml
Expand Up @@ -11,6 +11,7 @@ paralipomena: http://dev.digital-humanities.de/ci/job/faust-gen-fast/lastSuccess
genetic_bar_graph: http://dev.digital-humanities.de/ci/job/faust-gen-fast/lastSuccessfulBuild/artifact/target/www/data/genetic_bar_graph.json # JSON file
report_dir: target/macrogenesis # where to save reports and graphs
save_config: target/config.yaml # YAML file to save the config actually used
order: target/macrogenesis/order.xml # where to save the determined order
scene_xml: # XML file with scene information


Expand Down
4 changes: 3 additions & 1 deletion src/macrogen/main.py
Expand Up @@ -25,8 +25,10 @@ def main(argv=sys.argv):
if options.output:
graphs.save(options.output)

if not options.skip_reports:
if config.order:
report.write_order_xml(graphs)

if not options.skip_reports:
report.generate_reports(graphs)
render_all()

Expand Down
10 changes: 5 additions & 5 deletions src/macrogen/report.py
Expand Up @@ -1095,8 +1095,8 @@ def report_unused(graphs: MacrogenesisInfo):


def write_order_xml(graphs):
target: Path = config.path.report_dir
logger.debug('Writing reports to %s', target.absolute())
order_xml: Path = config.path.order or config.path.report_dir / 'order.xml'
logger.debug('Writing order file to %s', order_xml.absolute())
F = ElementMaker(namespace='http://www.faustedition.net/ns', nsmap=config.namespaces)
root = F.order(
Comment('This file has been generated from the macrogenesis data. Do not edit.'),
Expand All @@ -1110,12 +1110,12 @@ def write_order_xml(graphs):
for index, witness in enumerate(graphs.order_refs(), start=1)
if isinstance(witness, Witness)],
generated=datetime.now().isoformat())
target.mkdir(parents=True, exist_ok=True)
root.getroottree().write(str(target / 'order.xml'), pretty_print=True)
order_xml.parent.mkdir(parents=True, exist_ok=True)
root.getroottree().write(str(order_xml), pretty_print=True)

stats = graphs.year_stats()
data = dict(max=max(stats.values()), counts=stats)
with (target / 'witness-stats.json').open('wt', encoding='utf-8') as out:
with (config.path.report_dir / 'witness-stats.json').open('wt', encoding='utf-8') as out:
json.dump(data, out)


Expand Down

0 comments on commit d0470bd

Please sign in to comment.