Skip to content

Commit

Permalink
Create copies instead
Browse files Browse the repository at this point in the history
  • Loading branch information
PSU3D0 committed Oct 7, 2024
1 parent 9dedc24 commit 0a20b3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docprompt/tasks/ocr/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def contribute_to_document_node(

page_node = document_node.page_nodes[page_number - 1]
if hasattr(page_node.metadata, "ocr_results"):
page_node.metadata.ocr_results = self
page_node.metadata.ocr_results = self.model_copy(
update={"raster_image": None}
)
else:
super().contribute_to_document_node(document_node, page_number=page_number)

Expand All @@ -80,5 +82,3 @@ def contribute_to_document_node(
page_number=page_number,
image_bytes=self.raster_image,
)

self.raster_image = None # We need to clear this for memory reasons
2 changes: 1 addition & 1 deletion docprompt/tasks/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def contribute_to_document_node(
), "Page number must be less than or equal to the number of pages in the document"

page_node = document_node.page_nodes[page_number - 1]
page_node.metadata.task_results[self.task_key] = self
page_node.metadata.task_results[self.task_key] = self.model_copy()


TTaskInput = TypeVar("TTaskInput") # What invoke requires
Expand Down

0 comments on commit 0a20b3a

Please sign in to comment.