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

GUI Settings not working #377

Open
SamedVossberg opened this issue Nov 7, 2024 · 2 comments
Open

GUI Settings not working #377

SamedVossberg opened this issue Nov 7, 2024 · 2 comments
Assignees
Labels
bug Something isn't working gui Bugs related to the PyNM graphical interface

Comments

@SamedVossberg
Copy link
Contributor

I don't know if this might already be fixed on another branch but at least on the gui branch the Settings don't really work.
They do not change or affect the stream in the backend. Although setting updated are logged in the backend, the actual settings of the stream do not change nor does the data being pushed through the socket.

This does not as initially thought only affect PSD but all settings and features.

@SamedVossberg SamedVossberg added bug Something isn't working gui Bugs related to the PyNM graphical interface labels Nov 7, 2024
@timonmerk
Copy link
Contributor

I can reproduce the bug. Also on the better_settings_layout branch I am not able to see under localhost:54321 the webpage.

When looking at localhost:50001 I can see the frontpage, but when clicking on settings I get the following exceptions:

[FastAPI INFO (11:09:28)]: connection open
[FastAPI INFO (11:09:28)]: connection closed
[FastAPI ERROR (11:09:28)]: Exception in ASGI application
Traceback (most recent call last):
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 242, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 152, in __call__
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 77, in __call__
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 460, in handle
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/staticfiles.py", line 91, in __call__
    assert scope["type"] == "http"
           ^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
[FastAPI INFO (11:09:28)]: connection open
[FastAPI INFO (11:09:28)]: connection closed
[FastAPI access (11:09:29)]: 127.0.0.1:63864 - "GET /api/settings HTTP/1.1" 200
[FastAPI INFO (11:09:29)]: ('127.0.0.1', 63866) - "WebSocket /ws" [accepted]
[FastAPI ERROR (11:09:29)]: Exception in ASGI application
Traceback (most recent call last):
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 242, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 152, in __call__
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 77, in __call__
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 362, in handle
    await self.app(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 95, in app
    await wrap_app_handling_exceptions(app, session)(scope, receive, send)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/routing.py", line 93, in app
    await func(session)
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 383, in app
    await dependant.call(**solved_result.values)
  File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/gui/backend/app_backend.py", line 423, in websocket_endpoint
    await self.websocket_manager_features.connect(websocket)
  File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/gui/backend/app_socket.py", line 20, in connect
    await websocket.accept()
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/websockets.py", line 109, in accept
    await self.send({"type": "websocket.accept", "subprotocol": subprotocol, "headers": headers})
  File "/Users/Timon/Documents/py_neuromodulation/.venv/lib/python3.11/site-packages/starlette/websockets.py", line 79, in send
    raise RuntimeError(
RuntimeError: Expected ASGI message "websocket.send" or "websocket.close", but got 'websocket.accept'

@timonmerk
Copy link
Contributor

Ok, after looking more into depth into that I found the bug. When starting the stream we're not taking into account the updated settings. The run function is simply started here:

asyncio.create_task(self.stream.run(

But we would need to update the settings like that:

self.stream.settings = self.settings

I will push this change into your branch @SamedVossberg.

@toni-neurosc When doing those updates I get a pydantic error:

[FastAPI INFO (11:42:14)]: Starting stream
[FastAPI access (11:42:14)]: ::1:50499 - "POST /api/stream-control HTTP/1.1" 200
[FastAPI INFO (11:42:14)]: setup stream Process
Task exception was never retrieved
future: <Task finished name='Task-31' coro=<Stream.run() done, defined at /Users/Timon/Documents/py_neuromodulation/py_neuromodulation/stream/stream.py:200> exception=TypeError("Resampler.init() got an unexpected keyword argument 'field_type'")>
Traceback (most recent call last):
File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/stream/stream.py", line 248, in run
self.data_processor = DataProcessor(
^^^^^^^^^^^^^^
File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/stream/data_processor.py", line 64, in init
self.preprocessors = DataPreprocessor(
^^^^^^^^^^^^^^^^^
File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/processing/data_preprocessor.py", line 69, in init
self.preprocessors: list[NMPreprocessor] = [
^
File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/processing/data_preprocessor.py", line 70, in
instantiate_preprocessor(preprocessor_class, preprocessor_name)
File "/Users/Timon/Documents/py_neuromodulation/py_neuromodulation/processing/data_preprocessor.py", line 67, in instantiate_preprocessor
return preprocessor_class(**args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Resampler.init() got an unexpected keyword argument 'field_type'

I even get this error if all preprocessing steps are deleted, so the list of empty: preprocessing: [].

It would be great to find out why that could be the reason.

@timonmerk timonmerk mentioned this issue Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gui Bugs related to the PyNM graphical interface
Projects
None yet
Development

No branches or pull requests

3 participants