Skip to content

Commit

Permalink
fixed loading
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed May 9, 2019
1 parent f8451aa commit 3c0d920
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/macrogen/graph.py
Expand Up @@ -246,6 +246,10 @@ def _build_index(self):
def _augment_details(self):
logger.info('Augmenting refs with data from graphs')
for index, ref in enumerate(self.order_refs(), start=1):
if ref not in self.dag:
ref.earliest = EARLIEST
ref.latest = LATEST
continue
ref.index = index
ref.rank = self.closure.in_degree(ref)
max_before_date = max((d for d, _ in self.closure.in_edges(ref) if isinstance(d, date)),
Expand Down Expand Up @@ -287,7 +291,8 @@ def save(self, outfile: Path):
pickle.dump(self.simple_cycles, sc_entry)
with zip.open('order.json', 'w') as order_entry:
text = TextIOWrapper(order_entry, encoding='utf-8')
json.dump([ref.uri for ref in self.order], text)
json.dump([ref.uri for ref in self.order], text, indent=True)
text.flush()
with zip.open('config.yaml', 'w') as config_entry:
config.save_config(config_entry)
with zip.open('base.yaml', 'w') as base_entry:
Expand All @@ -303,7 +308,8 @@ def _load_from(self, load_from: Path):
with zip.open('simple_cycles.pickle', 'r') as sc_entry:
self.simple_cycles = pickle.load(sc_entry)
with zip.open('order.json', 'r') as order_entry:
uris = json.load(order_entry)
text = TextIOWrapper(order_entry, encoding='utf-8')
uris = json.load(text)
self.order = [Witness.get(uri) for uri in uris]
self._build_index()

Expand Down
2 changes: 1 addition & 1 deletion src/macrogen/report.py
Expand Up @@ -1215,7 +1215,7 @@ def rel_scenes(ref: Reference) -> List[str]:
if ref.earliest > EARLIEST and ref.latest < LATEST]
with (config.path.report_dir / 'timeline.json').open("wt") as data_out:
json.dump(data, data_out)
(config.path.report_dir / 'timeline.html').write_binary(pkg_resources.resource_string('macrogen', 'timeline.html'))
(config.path.report_dir / 'timeline.html').write_bytes(pkg_resources.resource_string('macrogen', 'timeline.html'))


def report_inscriptions(info: MacrogenesisInfo):
Expand Down

0 comments on commit 3c0d920

Please sign in to comment.