Skip to content

Commit

Permalink
fix: reset file pointer after writing
Browse files Browse the repository at this point in the history
  • Loading branch information
zaldivards committed Sep 3, 2024
1 parent 4c19cc5 commit 3e1cf2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/contextqa/services/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def load_and_preprocess(self, filename: str, file_: BinaryIO, session: Session)
file_writer = NamedTemporaryFile(mode="wb", suffix=f"{settings.tmp_separator}{filename}")
path = file_writer.name
file_writer.write(source_content)
finally:
file_writer.seek(0)
loader: BaseLoader = LOADERS[extension](str(path))
documents = loader.load()
finally:
file_writer.close()

# we do not want to split csv files as they are splitted by rows
Expand Down

0 comments on commit 3e1cf2b

Please sign in to comment.