garrettgu10 / python-workers-demos

2 stars 1 forks source link

Demos broken? #5

Open irvinebroque opened 3 months ago

irvinebroque commented 3 months ago

npx wrangler@latest dev in each of the demo repos:

FastAPI demo

✘ [ERROR] PythonError: Traceback (most recent call last):

    File "/lib/python312.zip/_pyodide/_base.py", line 629, in pyimport_impl
      res = __import__(stem, fromlist=fromlist)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/session/metadata/worker.py", line 13, in <module>
      from fastapi import FastAPI, Request
    File "/lib/python3.12/site-packages/fastapi/__init__.py", line 7, in <module>
      from .applications import FastAPI as FastAPI
    File "/lib/python3.12/site-packages/fastapi/applications.py", line 16, in <module>
      from fastapi import routing
    File "/lib/python3.12/site-packages/fastapi/routing.py", line 22, in <module>
      from fastapi import params
    File "/lib/python3.12/site-packages/fastapi/params.py", line 5, in <module>
      from fastapi.openapi.models import Example
    File "/lib/python3.12/site-packages/fastapi/openapi/models.py", line 4, in <module>
      from fastapi._compat import (
    File "/lib/python3.12/site-packages/fastapi/_compat.py", line 24, in <module>
      from starlette.datastructures import UploadFile
    File "/lib/python3.12/site-packages/starlette/datastructures.py", line 7, in <module>
      from starlette.concurrency import run_in_threadpool
    File "/lib/python3.12/site-packages/starlette/concurrency.py", line 8, in <module>
      import anyio.to_thread
  ModuleNotFoundError: No module named 'anyio'

      at new_error (pyodide-internal:generated/pyodide.asm:18:9998)
      at [object Object]x16c818
      at [object Object]x16c972
      at Module._pythonexc2js (pyodide-internal:generated/pyodide.asm:18:607968)
      at Module.callPyObjectKwargs (pyodide-internal:generated/pyodide.asm:18:64098)
      at Module.callPyObject (pyodide-internal:generated/pyodide.asm:18:65055)
      at Function.apply (pyodide-internal:generated/pyodide.asm:18:79132)
      at Object.apply (pyodide-internal:generated/pyodide.asm:18:77371)
      at Object.pyimport (pyodide-internal:generated/pyodide.asm:18:102887)
      at pyimportMainModule (pyodide:python-entrypoint-helper:104:18)
      at null.<anonymous> (pyodide:python-entrypoint-helper:117:24)
      at async Object.fetch (pyodide:python-entrypoint-helper:126:30)

Langchain

[wrangler:inf] GET / 500 Internal Server Error (4180ms)
✘ [ERROR] PythonError: Traceback (most recent call last):

    File "/lib/python312.zip/_pyodide/_base.py", line 629, in pyimport_impl
      res = __import__(stem, fromlist=fromlist)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/session/metadata/worker.py", line 2, in <module>
      from langchain.chat_models import ChatOpenAI
    File "/lib/python3.12/site-packages/langchain/chat_models/__init__.py", line 23, in <module>
      from langchain.utils.interactive_env import is_interactive_env
    File "/lib/python3.12/site-packages/langchain/utils/__init__.py", line 25, in <module>
      from langchain.utils.math import cosine_similarity, cosine_similarity_top_k
    File "/lib/python3.12/site-packages/langchain/utils/math.py", line 1, in <module>
      from langchain_community.utils.math import (
  ModuleNotFoundError: No module named 'langchain_community'

hello world

[wrangler:inf] GET / 500 Internal Server Error (1932ms)
✘ [ERROR] TypeError: Cannot read properties of undefined (reading 'callRelaxed')

      at Object.fetch (pyodide:python-entrypoint-helper:127:37)
garrettgu10 commented 3 months ago

Fixed by bumping workerd version in Wrangler & updating the langchain demo to not use the langchain package that imports the world.

Verify with npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8253708866/npm-package-wrangler-5230 dev