Skip to content

Commit

Permalink
Persist doc only when no error happens during parsing (fix HazyResear…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiromu Hota committed Jul 30, 2020
1 parent a7ecaf9 commit 1fa1406
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/fonduer/utils/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ def run(self) -> None:
# Merge the object with the session owned by the current child process.
# If transient (ie not saved), save the object to the database.
# If not, load it from the database w/o the overhead of reconciliation.
if inspect(doc).transient: # This only happens during parser.apply
doc = session.merge(doc, load=True)
else:
if not inspect(doc).transient:
doc = session.merge(doc, load=False)
y = self.apply(doc, **self.apply_kwargs)
if y and inspect(y).transient: # This only happens during parser.apply
y = session.merge(y, load=True)
self.out_queue.put((doc.name, y))
session.commit()
session.close()
Expand Down

0 comments on commit 1fa1406

Please sign in to comment.