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

Lite: Remove the workaround pinning the FastAPI version #6010

Closed
whitphx opened this issue Oct 19, 2023 · 2 comments · Fixed by #6036
Closed

Lite: Remove the workaround pinning the FastAPI version #6010

whitphx opened this issue Oct 19, 2023 · 2 comments · Fixed by #6036
Labels
enhancement New feature or request gradio-lite Related to the @gradio/lite library

Comments

@whitphx
Copy link
Member

whitphx commented Oct 19, 2023

I created this PR #5987 as the simplest workaround for the following error.
However, it should be replaced a better solution e.g. resolving the proper version of typing_extensions.

Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 571, in eval_code_async
    await CodeRunner(
  File "/lib/python311.zip/_pyodide/_base.py", line 394, in run_async
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 1, in <module>
  File "/lib/python3.11/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/lib/python3.11/site-packages/gradio/components/__init__.py", line 1, in <module>
    from gradio.components.annotated_image import AnnotatedImage
  File "/lib/python3.11/site-packages/gradio/components/annotated_image.py", line 14, in <module>
    from gradio.components.base import IOComponent, _Keywords
  File "/lib/python3.11/site-packages/gradio/components/base.py", line 20, in <module>
    from fastapi import UploadFile
  File "/lib/python3.11/site-packages/fastapi/__init__.py", line 7, in <module>
    from .applications import FastAPI as FastAPI
  File "/lib/python3.11/site-packages/fastapi/applications.py", line 16, in <module>
    from fastapi import routing
  File "/lib/python3.11/site-packages/fastapi/routing.py", line 22, in <module>
    from fastapi import params
  File "/lib/python3.11/site-packages/fastapi/params.py", line 5, in <module>
    from fastapi.openapi.models import Example
  File "/lib/python3.11/site-packages/fastapi/openapi/models.py", line 4, in <module>
    from fastapi._compat import (
  File "/lib/python3.11/site-packages/fastapi/_compat.py", line 20, in <module>
    from fastapi.exceptions import RequestErrorModel
  File "/lib/python3.11/site-packages/fastapi/exceptions.py", line 6, in <module>
    from typing_extensions import Annotated, Doc  # type: ignore [attr-defined]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'Doc' from 'typing_extensions' (/lib/python3.11/site-packages/typing_extensions.py)
@whitphx whitphx added the enhancement New feature or request label Oct 19, 2023
@abidlabs abidlabs added the gradio-lite Related to the @gradio/lite library label Oct 19, 2023
@freddyaboulton
Copy link
Collaborator

@whitphx see this issue: pyodide/pyodide#4234 (comment) I think we may need to set the typing-extensions version ourselves for gradio/lite

@whitphx
Copy link
Member Author

whitphx commented Oct 20, 2023

@freddyaboulton Thank you!
Actually there is already a list of manually resolved packages here for the same issue with micropip, so this would be one of them.

await micropip.install(["markdown-it-py[linkify]~=2.2.0"]); // On 3rd June 2023, markdown-it-py 3.0.0 has been released. The `gradio` package depends on its `>=2.0.0` version so its 3.x will be resolved. However, it conflicts with `mdit-py-plugins`'s dependency `markdown-it-py >=1.0.0,<3.0.0` and micropip currently can't resolve it. So we explicitly install the compatible version of the library here.
await micropip.install(["anyio==3.*"]); // `fastapi` depends on `anyio>=3.4.0,<5` so its 4.* can be installed, but it conflicts with the anyio version `httpx` depends on, `==3.*`. Seems like micropip can't resolve it for now, so we explicitly install the compatible version of the library here.
await micropip.install(["fastapi<0.104.0"]); // XXX: Workaround for #5986.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gradio-lite Related to the @gradio/lite library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants