Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore Use pdf library to check file without extension #184

Merged

Conversation

yuming-long
Copy link
Contributor

Summary

Instead of manually checking filename with .pdf extension and return is_pdf = false -> use currently pdf library to read file content to decide if the file content is valid pdf

@awalker4
Copy link
Collaborator

LGTM! I'd just suggest removing the logging when a file can't be loaded in pypdf. For a .doc, I see this:

INFO: Preparing to split document for partition.
ERROR: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
WARNING: The file does not appear to be a valid PDF.
INFO: Partitioning without split.

If any non pdf is expected to hit this path, we can remove the scary ERROR and WARNING.

@yuming-long yuming-long changed the title chore [RUDOLPH-98] Use pdf library to check file without extension chore Use pdf library to check file without extension Sep 26, 2024
Copy link
Collaborator

@awalker4 awalker4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending the last comment!

src/unstructured_client/_hooks/custom/pdf_utils.py Outdated Show resolved Hide resolved
@yuming-long yuming-long enabled auto-merge (squash) September 26, 2024 23:19
@yuming-long yuming-long merged commit 0c95c76 into main Oct 2, 2024
7 checks passed
@yuming-long yuming-long deleted the yuming/RUDOLPH-98_pdf_split_not_relay_on_file_extend branch October 2, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants