spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.25k stars 1.6k forks source link

Use runcell, runfile and debugfile from external kernel when an instance of spyder-kernels #8084

Open bcolsen opened 5 years ago

bcolsen commented 5 years ago

Now that spyder-kernels is a separate package it should be possible to detect whether an external kernel is a spyder-kernels instance and use runcell, runfile and debugfile for code execution.

@ccordoba12 said:

Also, we need to change this a little bit. runcell will also work in external Spyder kernels (i.e. kernels started with python -m spyder_kernels.console).

So we need to add a method to client that detects if kernels are of Spyder kind or not, and then avoid using runcell to run the code if they are not.

@bcolsen said:

I think this might be best left for another PR (I can make the issue) since this is true for the run_script function above using runfile() instead of %run on internal consoles as well. The changes might as well be made at the some time.

I guess currently the run_script function wouldn't work too well on a remote machine unless the local files were mirrored in the remote machine. If this is the case one solution would be to run the contents of the whole file through runcell. Of course having real remote file editing would be better, but in the near term it could make remote kernels more friendly.

bcolsen commented 5 years ago

Just an idea extra idea that could be implemented here.

As far as I can see currently runfile doesn't work very well on remote external connection because they don't have access to the local file system. This could be resolved with remote editing but that is pretty tricky. In the mean time we could use the runcell function to send the whole file contents to the remote kernel when when a user activate the runfile shortcut on a remote kernel.