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

Use filetype for better type detection in GradIO #569

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sysradium
Copy link
Contributor

@sysradium sysradium commented Feb 9, 2025

An attempt to fix #566

@sysradium sysradium changed the title use python-magic for better type detection in GradIO Use python-magic for better type detection in GradIO Feb 9, 2025
@sysradium sysradium force-pushed the gradio-file-texten-detection branch from 4a7cfcb to e8f20f6 Compare February 9, 2025 12:58
@sysradium sysradium changed the title Use python-magic for better type detection in GradIO Use filetype for better type detection in GradIO Feb 9, 2025
@sysradium sysradium force-pushed the gradio-file-texten-detection branch from e8f20f6 to 2349ff7 Compare February 9, 2025 12:59
@aymeric-roucher
Copy link
Collaborator

@sysradium feel free to continue work on this PR now that #342 is merged!

@sysradium
Copy link
Contributor Author

@aymeric-roucher

Thanks. I will introduce tests as well.

@sysradium sysradium marked this pull request as draft February 15, 2025 15:58
@sysradium sysradium force-pushed the gradio-file-texten-detection branch 6 times, most recently from 532d4fa to 234c5f6 Compare February 18, 2025 14:30
@sysradium sysradium marked this pull request as ready for review February 18, 2025 14:30
@sysradium
Copy link
Contributor Author

@aymeric-roucher added tests.


def tearDown(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove this method?

Copy link
Contributor Author

@sysradium sysradium Mar 3, 2025

Choose a reason for hiding this comment

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

Because it is no-longer needed. Each test receives its own file_upload_dir, tmpdir fixture which are automatically wiped out by pytest itself.

@@ -20,7 +20,7 @@ dependencies = [
"pillow>=11.0.0",
"markdownify>=0.14.1",
"duckduckgo-search>=6.3.7",
"python-dotenv"
"python-magic>=0.4.27,<0.5.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is adding this import really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aymeric-roucher

It is needed if we want to use python-magic for filetype detection. If we don't want then the most of the pr is pointless.

@sysradium sysradium force-pushed the gradio-file-texten-detection branch from 38a7643 to 4e8c077 Compare March 3, 2025 20:30
@sysradium sysradium force-pushed the gradio-file-texten-detection branch from 4e8c077 to 5d53b81 Compare March 3, 2025 20:30
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.

[BUG] GradioUI’s uploadfile Function Incorrectly Modifies File Extensions
2 participants