Skip to content

[Dash] Fix environment variable LOGIN #183

@RonanMorgan

Description

@RonanMorgan

Wanted Behavior

if LOGIN=True in your .env file (or if the LOGIN env var is not set) you need to login through a connection page

if LOGIN= False, the pyro-platform will use the API_LOGIN and the API_PWD environment variables in order to gather a token from the API so you don't need to login through the page.

Current Behavior

LOGIN=False conduct to the following bug :

2025-01-30 12:02:25,238 - werkzeug - INFO - 127.0.0.1 - - [30/Jan/2025 12:02:25] "GET /_dash-dependencies HTTP/1.1" 200 -
2025-01-30 12:02:25,311 - logging_config - INFO - Showing homepage layout (default language: French).
2025-01-30 12:02:25,524 - werkzeug - INFO - 127.0.0.1 - - [30/Jan/2025 12:02:25] "GET /assets/images/favicon.ico?m=1717416044.6698818 HTTP/1.1" 200 -
2025-01-30 12:02:25,544 - main - ERROR - Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3653, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc
    cpdef get_loc(self, object val):
  File "pandas/_libs/index.pyx", line 155, in pandas._libs.index.IndexEngine.get_loc
    val = self._check_type(val)
  File "pandas/_libs/index_class_helper.pxi", line 19, in pandas._libs.index.Float64Engine._check_type
KeyError: 'lat'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/dash/dash.py", line 1373, in dispatch
    ctx.run(
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/dash/_callback.py", line 465, in add_context
    output_value = _invoke_callback(func, *func_args, **func_kwargs)
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/dash/_callback.py", line 40, in _invoke_callback
    return func(*args, **kwargs)  # %% callback invoked %%
  File "/home/ronan/Bureau/Freelance/Pyronear/pyro-platform/app/index.py", line 47, in display_page
    return homepage_layout(user_token, api_cameras, lang="fr")
  File "/home/ronan/Bureau/Freelance/Pyronear/pyro-platform/app/pages/homepage.py", line 244, in homepage_layout
    build_alerts_map(api_cameras),
  File "/home/ronan/Bureau/Freelance/Pyronear/pyro-platform/app/utils/display.py", line 157, in build_alerts_map
    client_sites["lat"].median(),
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/pandas/core/frame.py", line 3761, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/ronan/Bureau/Freelance/Pyronear/venv_pyro/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3655, in get_loc
    raise KeyError(key) from err
KeyError: 'lat'

The interface showing nothing special :
Image

Development advise :

  • you should use the private mode of your browser
  • you can use the pyro-envdev repo, launch the command "make run-api" and launch the plateform with this repo locally :
    python app/index.py --host 0.0.0.0 --port 8050

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions