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

PR: Add command line option to connect to an existing kernel at startup (IPython console) #23444

Merged
merged 9 commits into from
Jan 15, 2025

Conversation

Social-Mean
Copy link
Contributor

@Social-Mean Social-Mean commented Jan 10, 2025

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

Issue(s) Resolved

Fixes #23130

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: Social-Mean

@Social-Mean Social-Mean changed the title PR: IPython console: Start Spyder and connect to an existing ipython kernel [WIP] PR: IPython console: Start Spyder and connect to an existing ipython kernel Jan 10, 2025
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Social-Mean for your work on this!

spyder/app/cli_options.py Outdated Show resolved Hide resolved
spyder/plugins/ipythonconsole/plugin.py Outdated Show resolved Hide resolved
@ccordoba12 ccordoba12 added this to the v6.0.4 milestone Jan 10, 2025
@ccordoba12 ccordoba12 changed the title [WIP] PR: IPython console: Start Spyder and connect to an existing ipython kernel [WIP] PR: Add command line option to connect to an existing kernel at startup (IPython console) Jan 10, 2025
@pep8speaks
Copy link

pep8speaks commented Jan 12, 2025

Hello @Social-Mean! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 563:77: W291 trailing whitespace

Comment last updated at 2025-01-15 17:34:01 UTC

@Social-Mean
Copy link
Contributor Author

Social-Mean commented Jan 12, 2025

I need help! Spyder is not connected to the specific kernel. The reproduction process is as follows:

  • Start an ipython kernel.

    (spyder-dev) $ python -m spyder_kernels.console
    

    This will output like:

    (spyder-dev) C:\Users\username>python -m spyder_kernels.console
    NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.
    
    To exit, you will have to explicitly quit this process, by either sending
    "quit" from a client, or using Ctrl-\ in UNIX-like environments.
    
    To read more about this, see https://github.com/ipython/ipython/issues/2049
    
    
    To connect another client to this kernel, use:
     --existing kernel-12345.json
    

    So we get the connection file is kernel-12345.json

  • Start Spyder with --connect-to-kernel=kernel-*.json option (run the following command in a new terminal window):

    (spyder-dev) $ python bootstrap.py -- --connect-to-kernel=kernel-12345.json
    

Now Spyder can start normally, but a new kernel is created as before, instead of connecting to the specified kernel.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Social-Mean, last comments then this should be ready.

And about what you said:

Start Spyder with --connect-to-kernel=kernel-*.json option

You don't need to use = to pass command line options, so it needs to be

spyder --connect-to-kernel kernel-*.json

I tested that with my suggestion below and things are working as expected.

spyder/plugins/ipythonconsole/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/ipythonconsole/plugin.py Show resolved Hide resolved
@Social-Mean Social-Mean marked this pull request as ready for review January 15, 2025 01:11
@Social-Mean Social-Mean changed the title [WIP] PR: Add command line option to connect to an existing kernel at startup (IPython console) PR: Add command line option to connect to an existing kernel at startup (IPython console) Jan 15, 2025
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this @Social-Mean!

Note: I added an entry to our Changelog to mention the small API change you did here.

@ccordoba12 ccordoba12 merged commit c943b16 into spyder-ide:master Jan 15, 2025
17 checks passed
@ccordoba12
Copy link
Member

@meeseeksdev please backport to 6.x

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

Successfully merging this pull request may close these issues.

Add command line option to connect to an existing kernel
3 participants