facebookresearch / labgraph

LabGraph is a Python framework for rapidly prototyping experimental systems for real-time streaming applications. It is particularly well-suited to real-time neuroscience, physiology and psychology experiments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebSocket Connection Interrupted on LabGraph Monitor

fzchriha opened this issue ¡ comments

🐛 Bug

WebSocket connection is interrupted when trying to display the real-time messages on Labgraph Monitor (frontend)

To Reproduce

Steps to reproduce the behavior:

  1. python3 labgraph/examples/labgraph_monitor_example.py
  2. cd extensions/prototypes/labgraph_monitor
  3. yarn start
  4. Click on RandomMessage Node
    Demo
    demo_error2

Expected behavior

After a few seconds the real-time data freezes, check the terminal where the WebSocket is running it will display the following error:
- WS_SERVER_NODE: Raised an exception: RuntimeError("Task <Task pending name='Task-162949' coro=<WSAPIServerNode.ws_server_publisher() running at /Users/fatimazahra.chriha/Desktop/mlh/spring2022/labgraph/labgraph/websockets/ws_server/ws_api_node_server.py:125>> got Future <Future pending> attached to a different loop")

Screen Shot 2022-04-02 at 3 20 49 PM

Environment


 - LabGraph Version:
 - OS: Mac
 - Python version: Python 3.8.13

@fzchriha can you send a screenshot of the error you're getting? i'm trying understand the behavior from the gif, but it loops too fast I can't see what's written in the terminal

Hi @dtemir It's in the description above:
- WS_SERVER_NODE: Raised an exception: RuntimeError("Task <Task pending name='Task-162949' coro=<WSAPIServerNode.ws_server_publisher() running at /Users/fatimazahra.chriha/Desktop/mlh/spring2022/labgraph/labgraph/websockets/ws_server/ws_api_node_server.py:125>> got Future <Future pending> attached to a different loop")

Here is the screenshot of the terminal
Screen Shot 2022-04-02 at 4 42 31 PM

@fzchriha yeah I see! I was just wondering if there something useful in the Python traceback that shows what parts of the code the error breaks

@fzchriha thank you! looking into that

@fzchriha just to be sure, this has been resolved?

#63 (comment)

No it hasn't that comment was for realtime data sync with frontend

@fzchriha could you update PR #63 to use the last version of Labgraph Monitor and see if that solves the issue. I tried it and it looks like working fine

demo

@bennaaym Hi Aymen I used the last version of labgraph monitor and for some reason when I try to connect using the latest changing @dtemir made (they work on my current PR) the status stays in IS CONNECTING and it never connects with the graph
Screen Shot 2022-04-11 at 4 39 33 PM

@fzchriha, be sure that there is .env.local that has the following key: REACT_APP_WS_API="ws://127.0.0.1:9000"

I have it there, but it still does not work

could you send another screenshot of both the server console and the frontend?

Frontend
Screen Shot 2022-04-11 at 4 59 47 PM

Backend
Screen Shot 2022-04-11 at 5 00 38 PM

Could you try to restart the app, that's essential to pick up the changes in the .env variables

Yes it won't work :(

hey guys, just commenting to see if you want this issue closed as it now works in #71 ?

Hi @dtemir,unfortunately, it still does not work. I will discuss it with Jimmy again in our next meeting. In the meanwhile can you try testing (frontend + backend) on your Mac machine?

@fzchriha sorry, I gave my mac to my sister for her school. But I just tested it on my Ubuntu 20.04 and the front-end + back-end seem to be working perfectly. Connected and disconnected a dozen of times without errors (except for back-end, which throws warnings whenever I disconnect). Do you think the bug is machine dependent then?

Do you think the bug is machine dependent then?

That's what I'm trying to test out, because Ayman tested it on windows & ubuntu and I'm the only one who has this issue & have a mac. So we are trying to weed out the possible causes. Otherwise, this error would be related to the websocket API config (labgraph internet code)

Hi @dtemir It's in the description above: - WS_SERVER_NODE: Raised an exception: RuntimeError("Task <Task pending name='Task-162949' coro=<WSAPIServerNode.ws_server_publisher() running at /Users/fatimazahra.chriha/Desktop/mlh/spring2022/labgraph/labgraph/websockets/ws_server/ws_api_node_server.py:125>> got Future <Future pending> attached to a different loop")

Here is the screenshot of the terminal Screen Shot 2022-04-02 at 4 42 31 PM

Just to be sure, it throws the same error described above?

@fzchriha Happy to quickly test out the code on my Mac.

Has the labgraph/examples/labgraph_monitor_example.py been renamed? I'm unable to find it in the repo.

yeah it's now under extensions/yaml_support/labgraph_monitor/examples/labgraph_monitor_example.py in #64

@garrettmflynn thank you, Garret, can you please use the extensions/yaml_support folder @dtemir has in #64

Looks like my installation of Buck isn't going to work—so I'm not sure I'll be able to run things today.
Screen Shot 2022-04-14 at 10 59 22 AM

There's a persistent error on homebrew install buck and, subsequently, on python3 setup.py install when buck can't be found on the PATH. I think it's a permissions thing—but I've tried everything (including re-installing Homebrew) I can find on the internet to no avail.

Any tips or suggestions for installation?

@garrettmflynn you don't need to configure labgraph in order to run the server + frontend. For the frontend just follow the readme and should cover it all

Oh sure. So you don't want me to run the extensions/yaml_support/labgraph_monitor/examples/labgraph_monitor_example.py like in your original To Reproduce section?

I've got the frontend running—though it's still quite unclear to me how to get the server running at ws://127.0.0.1:9000 despite adding the required .env.local file.

@garrettmflynn to run the server at ws://127.0.0.1:9000 you need to run python3 extensions/yaml_support/labgraph_monitor/examples/labgraph_monitor_example.py and it requires labgraph as it's actually running the graph to produce real-time data

*tip: to run both the front-end and back-end, I have two Git repos: labgraph and labgraph-1. The first repo is checking out PR #64 and the second repo is checking out PR #71.

  • In the first repo, I run python3 extensions/yaml_support/labgraph_monitor/examples/labgraph_monitor_example.py.
  • In the second repo I run yarn start with the .env.local file pointing at ws://127.0.0.1:9000

This is how I'm able to check out PR #71 in my second repo labgraph-1

git fetch upstream pull/71/head:fzchriha/lg_monitor_v2
git checkout fzchriha/lg_monitor_v2

This is how you can check out my PR #64 in first repo labgraph. I haven't tried it though bc I have it locally.

git fetch upstream pull/71/head:dtemir/real_time_messages
git checkout dtemir/real_time_messages

There's a persistent error on homebrew install buck and, subsequently, on python3 setup.py install when buck can't be found on the PATH. I think it's a permissions thing—but I've tried everything (including re-installing Homebrew) I can find on the internet to no avail.

Any tips or suggestions for installation?

Have you tried this approach by chance? https://github.com/facebookresearch/labgraph/blob/main/docs/installation/macos.md

I think we faced a similar issue with @fzchriha a while back, setting it up on Mac OS. Maybe that's the same problem here?

@dtemir Got a bit further. Any chance you know how to fix this error?

Screen Shot 2022-04-14 at 4 06 51 PM

@garrettmflynn just to be sure, what Python version are you using?

The recommended version is 3.8 and it might be because there's some incompatibility with 3.9

@dtemir Good question! I was on 3.9, though now have downgraded to 3.8.12. Here's the new error:
Screen Shot 2022-04-15 at 9 17 04 AM

@garrettmflynn thanks for trying it out with 3.8. Do you mind running labgraph$ python -m labgraph.examples.simple_viz just to make sure it's not just a python problem?

it shouldn't throw any errors and just start playing this matplotlib graph. That way it will tell me if the problem is Python, LabGraph itself, or my example
Screenshot from 2022-04-15 12-37-24

@dtemir After getting into this, I don't think I'll be able to get this test done. I'd assumed the process would be substantially easier—though it looks like my dev environment won't cooperate.

After I restarted my terminal, the python -m labgraph.examples.simple_viz errored out and the labgraph/examples/labgraph_monitor_example.py and its React counterpart in the Monitor errored after I clicked on the RandomMessage node inside the React UI. This was all on your branch, though, so I'd assume that's why it didn't work.

After this, I restarted the terminal again—and now neither of the files can be called again with the same error. I've spent a few hours, on and off, trying to get it working—but no luck.

Any further suggestions would be appreciated! Otherwise I'll just have to bow out for now.

no problem @garrettmflynn! thank you for taking your time