marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.93k stars 191 forks source link

Unable to connect to Github Copilot working in Github Codespaces #729

Open rorads opened 6 months ago

rorads commented 6 months ago

Describe the bug

I've ensured that Node is installed, and where the dialogue has prompted me to run authorisation via github, I've done so successfully. I have an active copilot subscription which works across local and Github Codespaces. I have successfully connected when running locally, and reproduced the steps in my Codespace, but without success.

Note that I've tried making all forwarded ports public within the Codespaces VS Code interface, as well as keeping them private. Neither has been successful.

Within Marimo, the issue presents as follows:

image

Please note that I have tried this in both Edge and Chrome, which makes no difference.

Environment

{
  "marimo": "0.2.1",
  "OS": "Linux",
  "OS Version": "6.2.0-1018-azure",
  "Processor": "x86_64",
  "Python Version": "3.10.13",
  "Binaries": {
    "Chrome": "--",
    "Node": "v20.10.0"
  },
  "Requirements": {
    "black": "23.12.1",
    "click": "8.1.7",
    "jedi": "0.19.1",
    "pymdown-extensions": "10.7",
    "starlette": "0.36.2",
    "tomlkit": "0.12.3",
    "typing_extensions": "4.8.0",
    "uvicorn": "0.27.0.post1"
  }
}

Code to reproduce

Actual code is minimal. On a fresh github codespace with python, just installing node (see env above) and Marimo, then running Marimo edit ... via the command line or through the Marimo VS Code extension.

mscolnick commented 6 months ago

hey @rorads, Copilot will connect to a port 10 * <marimo-port>. For example, if marimo is open at 2178, Copilot will try to connect to ws://localhost:27180/copilot. If you look in your network tab, do you see why it fails to connect?

Can you try to hit this endpoint from your terminal to make sure it is accessible? e.g. curl http://localhost:27180. The expected response would be Upgrade Required.

jpambrun commented 6 months ago

Had the same issue, but when running from docker. This should be added to the troubleshooting section: https://docs.marimo.io/getting_started/index.html#github-copilot

jpambrun commented 6 months ago

Actually, opening the port 27180 helped, but it still wouldn't work. I can see the initialize methos jsonrpc ws message being sent, but no response comes back. The server has no related output.

the browser console then shows:

index-gVKbhhC8.js:1078 Uncaught (in promise) Error: Request timeout request took longer than 30000 ms to resolve
    at new i (index-gVKbhhC8.js:1078:17935)
    at index-gVKbhhC8.js:1078:20671
mscolnick commented 6 months ago

can you run marimo -l debug edit <file> - maybe there is some more hints in there.

Can you include the steps you have gotten thus far to run marimo in Codespaces - I can see if i can debug as well. I haven't used Codespaces, so not sure what is already installed vs what you installed manually.

jpambrun commented 6 months ago

Nothing obvious. The few first line suggest marimo is happy, but then the front end never gets any message back from :27180 even though it seems connected fine. This works outside of the docker container.

It does raise the question of where are the copilot credentials?

[D 240220 22:00:57 utils:98] Using config at /root/.marimo.toml
[D 240220 22:00:57 lifespans:56] Setup: lsp
[D 240220 22:00:57 lifespans:72] GitHub Copilot is enabled
[D 240220 22:00:57 sessions:616] Starting LSP server at port 27180...
[D 240220 22:00:57 sessions:622] ... running command: node /usr/local/lib/python3.11/dist-packages/marimo/_lsp/index.js --port 27180
[D 240220 22:00:57 sessions:629] ... node process return code (`None` means success): None
[D 240220 22:00:57 sessions:633] Started LSP server at port 27180
[D 240220 22:00:57 lifespans:56] Setup: watcher
[D 240220 22:00:57 lifespans:56] Setup: etc
[D 240220 22:00:57 lifespans:56] Setup: signal_handler
[D 240220 22:00:57 lifespans:56] Setup: logging

        Edit delme.py in your browser 📝

        URL: http://localhost:2718

[D 240220 22:00:57 lifespans:56] Setup: open_browser
[D 240220 22:01:14 ws:221] Websocket open request for session with id 668f9704-afa3-4248-99d6-9cf2dc715ef3
[D 240220 22:01:14 ws:224] Existing sessions: {}
[D 240220 22:01:14 sessions:550] Closing all sessions (sessions: {})
[D 240220 22:01:14 sessions:553] Closed all sessions.
[D 240220 22:01:14 sessions:448] Creating new session for id 668f9704-afa3-4248-99d6-9cf2dc715ef3
[D 240220 22:01:14 runtime:1122] Launching kernel
[D 240220 22:01:14 runtime:1246] received request CreationRequest(execution_requests=(ExecutionRequest(cell_id='Hbol', code="print('asdf')"),), set_ui_element_value_request=SetUIElementValueRequest(ids_and_values=[]))
[D 240220 22:01:14 runtime:437] Current set of errors: {}
[D 240220 22:01:14 runtime:307] registered cell Hbol
[D 240220 22:01:14 runtime:308] parents: set()
[D 240220 22:01:14 runtime:309] children: set()
[D 240220 22:01:14 runtime:336] graph:
        cell id Hbol
        parents {'Hbol': set()}
        children {'Hbol': set()}
        siblings {'Hbol': set()}
[D 240220 22:01:14 runtime:471] After mutation, syntax errors {}
[D 240220 22:01:14 runtime:472] Semantic errors {}
[D 240220 22:01:14 runtime:516] Final set of errors, after pruning valid cells: {}
[D 240220 22:01:14 ops:54] Broadcasting op: Variables(variables=[])
[D 240220 22:01:14 runtime:627] preparing to evaluate cells {'Hbol'}
[D 240220 22:01:14 ops:54] Broadcasting op: CellOp(cell_id='Hbol', output=None, console=None, status='queued', timestamp=1708466474.9434514)
[D 240220 22:01:14 runtime:653] final set of cells to run ['Hbol']
[D 240220 22:01:14 ops:54] Broadcasting op: RemoveUIElements(cell_id='Hbol')
[D 240220 22:01:14 runtime:664] running cell Hbol
[D 240220 22:01:14 ops:54] Broadcasting op: CellOp(cell_id='Hbol', output=None, console=[], status='running', timestamp=1708466474.9445224)
[D 240220 22:01:14 ops:54] Broadcasting op: CellOp(cell_id='Hbol', output=None, console=None, status='idle', timestamp=1708466474.9449737)
[D 240220 22:01:14 ops:54] Broadcasting op: CellOp(cell_id='Hbol', output=CellOutput(channel=output, mimetype='text/plain', data='', timestamp=1708466474.9451854), console=None, status='idle', timestamp=1708466474.9451873)
[D 240220 22:01:14 runtime:620] Finished run.
[D 240220 22:01:14 ops:54] Broadcasting op: CompletedRun()
[D 240220 22:01:14 ops:54] Broadcasting op: CellOp(cell_id='Hbol', output=None, console=CellOutput(channel=stdout, mimetype='text/plain', data='asdf\n', timestamp=1708466474.9551442), status=None, timestamp=1708466474.9551516)
jpambrun commented 6 months ago

Ok, so the config is in ~/.config/github-copilot/hosts.json, but knowing that doesn't help all that much.

Interestingly, I can reproduce the issue with some base image and not with others..

docker run -it --rm -p 2718:2718 -p 27180:27180 python /bin/bash
apt update && apt install -y nodejs && pip install marimo
marimo -l debug edit delme.py

WORKS^

docker run -it --rm -p 2718:2718 -p 27180:27180 tensorflow/tensorflow:2.15.0.post1 /bin/bash
apt update && apt install -y nodejs && pip install marimo
marimo -l debug edit delme.py

DOESN'T work^

mscolnick commented 6 months ago

thanks for this minimal repro. nothing comes to mind why those would be different. i can try to play around with both these setups and see if i notice anything.

cpbotha commented 6 months ago

FWIW, here's another reproducer:

pipx install marimo
marimo edit

Will give me "unable to connect" (copilot) with in the javascript console: "Uncaught (in promise) Error: Failed to connect to ws://localhost:27180/copilot at oPn (index-2gtEcE8Y.js:1156:1382) at async aPn.connect (index-2gtEcE8Y.js:1156:1799)"

When I use good old venv to create a marimo environment, with the same Python version 3.12.2 and same marimo 0.2.8, it works fine.

rorads commented 4 months ago

Apologies for not getting back sooner, but from my side this has been fixed in recent updates. I'm not sure if this was directly due to a fix, or if the original issue was a side effect of something which was changed elsewhere.

I won't close myself as others may still have an issue, but I'm happy for this to be closed.

Thank you for the great software - it's really useful and getting a lot of praise at work.