voxel51 / fiftyone

The open-source tool for building high-quality datasets and computer vision models
https://fiftyone.ai
Apache License 2.0
8.12k stars 541 forks source link

[BUG]App error with database_uri config #4819

Closed KirigiriSuzumiya closed 2 days ago

KirigiriSuzumiya commented 2 days ago

Describe the problem

the app page shows network error code 500. I got traceback like this in the graphql request

  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/server/context.py", line 40, in get_context
    return get_context(request=request, response=response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/server/context.py", line 26, in get_context
    db = get_async_db_conn(use_global=use_global_db_client)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/core/odm/database.py", line 417, in get_async_db_conn
    db = get_async_db_client(use_global=use_global)[fo.config.database_name]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/core/odm/database.py", line 408, in get_async_db_client
    return _async_connect(use_global)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/core/odm/database.py", line 239, in _async_connect
    _connect()
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/core/odm/database.py", line 233, in _connect
    establish_db_conn(fo.config)
  File "/home/stardust/miniconda3/envs/fiftyone-dev/lib/python3.12/site-packages/fiftyone/core/odm/database.py", line 200, in establish_db_conn
    raise FiftyOneConfigError(
fiftyone.core.config.FiftyOneConfigError: MongoDB could not be installed on your system. Please define a `database_uri` in your `fiftyone.core.config.FiftyOneConfig` to connect to yourown MongoDB instance or cluster 

But refer to the code I provided, fo.list_datasets() works well, which did get data from my mongodb, can anyone help?

Code to reproduce issue

import fiftyone as fo

if __name__ == "__main__":
    fo.config.database_uri = "mongodb://root:passwd@localhost:27017"
    fo.config.database_validation = False
    print(fo.list_datasets())
    # this works well , I get my dataset
    session = fo.launch_app()
    session.wait()

Provide a reproducible test case that is the bare minimum necessary to generate the problem. Please avoid sharing code that relies on your local data or datasets. Include a short video or screenshot if the bug is in the App.

my web page shows this: image

System information

Other info/logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Please do not use screenshots for sharing text. Code snippets should be used instead when providing tracebacks, logs, etc.

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?

benjaminpkane commented 2 days ago

HI @KirigiriSuzumiya. This is an issue with the server startup process which we are looking into. Defining the db settings as an environment variable before running your script should avoid the problem.

export FIFTYONE_DATABASE_URI=mongodb://root:passwd@localhost:27017
export FIFTYONE_DATABASE_VALIDATION=false
KirigiriSuzumiya commented 2 days ago

thk, it works!