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

Simple jupyter kernel doesn't work correctly #14146

Closed
1 task done
sigmaSd opened this issue Jul 11, 2024 · 6 comments · Fixed by #14608
Closed
1 task done

Simple jupyter kernel doesn't work correctly #14146

sigmaSd opened this issue Jul 11, 2024 · 6 comments · Fixed by #14608
Labels
defect [core label] python Python programming language support repl repl, etc

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Jul 11, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I have a simple jupyter kernel, that works in vscode/jupyter

In zed, repl run works the first time, then it only shows Queued

here is the do_execute override

def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=False):
        # Send the first JSON object to the process's standard input
        code_object = {"code": code}
        json_code = json.dumps(code_object)
        self.re.stdin.write(json_code.encode("utf-8"))
        self.re.stdin.write(b"\n")
        self.re.stdin.flush()

        # Read the first JSON object from the process's standard output
        json_result = self.re.stdout.readline().decode("utf-8")
        action_type = json.loads(json_result)

        if "Eval" in action_type:
            action = action_type["Eval"]
            self.send_response(self.iopub_socket, 'display_data', {
                'metadata': {},
                'data': {
                    action["mime_type"]: action["value"]
                }
            })

        return {'status': 'ok',
                'execution_count': self.execution_count,
                'payload': [],
                'user_expressions': {},
               }

I also tried the EchoKernel example from https://jupyter-client.readthedocs.io/en/latest/wrapperkernels.html and it errors as well, although with a different error, it doesn't connect at all

@rgbkrk would be great if you take a look

Environment

Zed: v0.145.0 (Zed Nightly 07dc405)
OS: Linux Wayland fedora 40
Memory: 7.6 GiB
Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
@sigmaSd sigmaSd added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels Jul 11, 2024
@notpeter notpeter added python Python programming language support repl repl, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Jul 11, 2024
@rgbkrk
Copy link
Member

rgbkrk commented Jul 11, 2024

Thanks for reporting this. I think this is a case where we're waiting for a shell reply and so no other shell requests go out. I'm going to tackle this next as I see it affects a good number of kernels in Rust and R. Python and Deno seem to send back shell replies in response to requests always.

@rgbkrk
Copy link
Member

rgbkrk commented Jul 11, 2024

For the moment, we're reliant on the kernelspecs having a language field in the kernelspec in order to detect if they can be run. For the sake of the echo kernel I've set the language to plain text so that I can open it on .txt files.

Using this kernelspec:

{"argv": ["/Users/kylekelley/.pyenv/versions/miniconda3-latest/envs/ker/bin/python", "-m", "echo_kernel", "-f", "{connection_file}"], "display_name": "Echo", "language": "plain text"}

That also requires setting the language in Zed to "Plain Text" for that txt file. I was then able to reproduce this:

image

I'll see what I can figure out next!

@rgbkrk
Copy link
Member

rgbkrk commented Jul 12, 2024

This bug is the same as the one I've experienced with the Ark (R) kernel, where we're stuck waiting for a kernel_info_reply before we can send any other shell messages. There's a bit of an architecture issue with the underlying library that I'll need to address (zeromq/zmq.rs#194). For the time being, I'm going to timeout waiting for replies and likely just not bother waiting for them (for now).

rgbkrk added a commit that referenced this issue Jul 16, 2024
Closes #14146, for the time being before a networking refactoring to
split reads and writes on the ROUTER/DEALER ZeroMQ sockets.
@rgbkrk
Copy link
Member

rgbkrk commented Jul 16, 2024

Ok I've opted to just not send KernelInfoRequest as a temporary fix. All is working well with the echo kernel. What's the kernel you were using I should also try this with @sigmaSd?

@rgbkrk
Copy link
Member

rgbkrk commented Jul 17, 2024

Try this out again with your kernel on Nightly when you get a chance.

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Jul 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect [core label] python Python programming language support repl repl, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants