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

[Dash] Fix environment variable LOGIN #183

Open
RonanMorgan opened this issue Jan 30, 2025 · 0 comments
Open

[Dash] Fix environment variable LOGIN #183

RonanMorgan opened this issue Jan 30, 2025 · 0 comments
Labels

Comments

@RonanMorgan
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant