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

Fastapi display in viewer does not work on Ubuntu #4949

Open
testlabauto opened this issue Oct 8, 2024 · 6 comments
Open

Fastapi display in viewer does not work on Ubuntu #4949

testlabauto opened this issue Oct 8, 2024 · 6 comments
Labels
area: viewer Issues related to Viewer category. lang: python theme: app builder

Comments

@testlabauto
Copy link
Contributor

System details:

Positron and OS details:

Ubuntu 24.04
Positron 2024.11.0 build 16

Interpreter details:

Python 3.10.12

Describe the issue:

The fastapi_example from qa-example-content does not render in the Viewer on Ubuntu.

Steps to reproduce the issue:

  1. Clone qa-example-content
  2. Run fastapi_example
  3. Note that the viewer url shows http://127.0.0.1:8000/docs but nothing is displayed

Expected or desired behavior:

FastAPI example works

Were there any error messages in the UI, Output panel, or Developer Tools console?

Uncaught SyntaxError: Identifier 'hostMessaging' has already been declared

@testlabauto
Copy link
Contributor Author

FYI @seeM @isabelizimm

@jonvanausdeln
Copy link
Contributor

On my windows box I get

C:\Users\JonVanausdeln\source\qa-example-content [main ≡ +0 ~1 -0 !]> C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\python.exe -m uvicorn --reload workspaces/python_apps/fastapi_example.fastapi_example:app
INFO:     Will watch for changes in these directories: ['C:\\Users\\JonVanausdeln\\source\\qa-example-content']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [5648] using WatchFiles
Process SpawnProcess-1:
Traceback (most recent call last):
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\asyncio\runners.py", line 118, in run    
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\asyncio\base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\server.py", line 69, in serve
    await self._serve(sockets)
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\server.py", line 76, in _serve
    config.load()
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\importer.py", line 22, in import_from_string
    raise exc from None
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\site-packages\uvicorn\importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'workspaces/python_apps/fastapi_example'

@juliasilge juliasilge added the area: viewer Issues related to Viewer category. label Oct 8, 2024
@seeM
Copy link
Contributor

seeM commented Oct 9, 2024

@jonvanausdeln this looks like a separate Windows-specific issue where our conversion from a file path (workspaces/python_apps/fastapi_example/fastapi_example.py) to a Python module import path (workspaces.python_apps.fastapi_example.fastapi_example) is not working as expected.

I'm not yet sure what's happening in the Ubuntu case.

@jonvanausdeln
Copy link
Contributor

@seeM , should I open a separate issue for windows?

@seeM
Copy link
Contributor

seeM commented Oct 10, 2024

@jonvanausdeln yes I think so

@sharon-wang
Copy link
Member

@testlabauto was this intermittent or consistently reproducible? I wonder if this is the same issue as #5187. I re-enabled the Fastapi test in #5265 which passed in the PR test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: viewer Issues related to Viewer category. lang: python theme: app builder
Projects
None yet
Development

No branches or pull requests

6 participants