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

Obtain variable value #626

Open
dantard opened this issue Nov 16, 2024 · 0 comments
Open

Obtain variable value #626

dantard opened this issue Nov 16, 2024 · 0 comments

Comments

@dantard
Copy link

dantard commented Nov 16, 2024

Hello,
I'm new to Jupyter and qtconsole and I'm not even sure this is the right place to ask.
I'm writing a Qt-based application that uses a QtKernelManager and RichJupyterWidget.
The QtKernelManager uses a connection_file to connect to a running Jupyter kernel. I'm able to perform commands programmatically on the server like for example:

        self.kernel_manager = QtKernelManager(connection_file=self.connection_file)
        self.kernel_manager.load_connection_file()
        self.kernel_client = self.kernel_manager.client()
        self.kernel_client.start_channels()
        # Execute command
        self.kernel_client.execute("foo=27")

If I connect a qtconsole to the same kernel I can see the variable a value has changed which is what I expect.

However, in my application, I don't know how to retrieve the value of the variable foo (if, for example, it has been changed). Previously, I was using QtInProcessKernelManager, which exposed the methods .kernel.shell.push() and .kernel.shell.user_ns.get(). However, I have not been able to make QtInProcessKernelManager work with an external kernel. On the other hand, the QtKernelManager does not expose any similar methods, presumably because the kernel is running in a different process.

In short, is there a way to retrieve local variables with a QtKernelManager?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant