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
Fixes URL resolution on Windows #3108
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3108-all-demos |
@abidlabs Is that test code supposed to fail on Windows with the latest gradio version? The gallery shows up correctly for me on windows. This is what I did. Lemme know if I messed something up cause I'm not used to windows development. Install gradio from Pypi in a virtualenv on WindowsRun the test caseGallery shows up for me 🤔The proposed change looks good to me though and the deployed demos are working fine - just want to make sure I'm testing properly |
Very strange, it isn't working for me on Windows @freddyaboulton. Can you try this simpler repro: from pathlib import Path
url = "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80"
Path(url).resolve() |
Yea calling WindowsUbuntuIt's strange it's broken for you since I just looked at the @app.head("/file={path:path}", dependencies=[Depends(login_check)])
@app.get("/file={path:path}", dependencies=[Depends(login_check)])
async def file(path: str, request: fastapi.Request):
abs_path = str(utils.abspath(path))
blocks = app.get_blocks()
if utils.validate_url(path):
return RedirectResponse(url=path, status_code=status.HTTP_302_FOUND) I wonder if something else is at play 🤔 |
Ahh it looks like it's a Python 3.9 vs. 3.10 thing, specifically on Windows 🤯 When I run the same code I asked you to run on Python 3.9, I get this error raised: Apparently, pathlib fixed it at some point in Python 3.10: python/cpython@4696f12 |
You're right, we do call This PR changes the order so that we only call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix + debugging with me @abidlabs !
Thank you @freddyaboulton! |
Previously, we would run
utils.abspath()
on a path before we knew whether it was a URL or a string path. On Windows, this would lead to an error if the path provided was a URL. This fixes that and makes the code a little clearer to read.Test code (run this on a Windows machine):