spyder-ide / spyder

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

Execute remote scripts in remote kernels under local Spyder #3065

Open samotracio opened 8 years ago

samotracio commented 8 years ago

I am trying to edit and run a script.py located in a remote server using a local Spyder running in a laptop.

I was able to successfully connect to the remote kernel running in the server and after mounting the remote directory using sshfs in a local folder in the laptop, Spyder can read and modify script.py with no problems.

However, using "Run" from the menu does not work (and for some reason uses %run instead of runfile())

  In[1]: %run "/home/uzer/someLocalDir/script.py"
  ERROR: File `'/home/uzer/someLocalDir/script.py'` not found

I understand this fails because that path is only locally defined, while in the server the code is in a different location , say "/home/uzer/some/remote/dir/script.py"

Is it possible to access the full path of the currently selected file in the Spyder editor (that is, the string "/home/uzer/someLocalDir/script.py") ? Mi idea is to implement a custom magic such as %remote_run, that takes this string, translates the directory structure from local to remote, and finally does %run real-remote-path . I know is not the best solution, but might work for specific cases.

Apologizes if this sounds more like a question than a actual issue report.

ccordoba12 commented 8 years ago

I think you don't need the quotes around the file name

samotracio commented 8 years ago

Thanks Carlos. Perhaps I didn't made myself clear.

The question can be rephrased as: From an interactive ipython console in Spyder, can I retrieve the path+filename.py of the file currently selected in the editor stack ?

I can see in editor.py that the class Editor(SpyderPluginWidget) defines the property _get_currentfilename(). But how can the running instance of the Editor be accessed from the console, if possible at all ?

FrancescoCappio commented 5 years ago

Hello, I am in the exact same situation. I would like to know if there is any progress on this

bcolsen commented 5 years ago

@FrancescoCappio Currently there is no capability for direct remote editing.

However, with the new spyder-kernels split, you can run a spyder-kernels instance on the server and get runfile on the server but you still need to put the remote file path in the runfile function.

goanpeca commented 5 years ago

@FrancescoCappio Currently there is no capability for direct remote editing.

We will work on this for a future release of spyder so we have full support for remote editing

FrancescoCappio commented 5 years ago

Thank you every body

@FrancescoCappio Currently there is no capability for direct remote editing.

However, with the new spyder-kernels split, you can run a spyder-kernels instance on the server and get runfile on the server but you still need to put the remote file path in the runfile function.

Where can I find this runfile function to manually edit it?

ccordoba12 commented 5 years ago

runfile is part of the kernel, so you can call it like any other builtin (e.g. range).

mdhaber commented 5 years ago

+1 on this, I think. Setting up a SciPy development environment in Windows is tricky, but setting one up in Windows Subsystem for Linux (WSL) is relatively easy. From Spyder on Windows, I can connect to a Python kernel running on WSL, but I'm having trouble editing/running files that live on WSL (like SciPy source files). I can browse for them, but when I try to open them nothing happens.

I've also tried running Spyder on WSL and using XMing to see the GUI, but no luck.

Any workarounds in the meantime would be appreciated!

pilotjoe commented 4 years ago

I'm eagerly awaiting this enhancement too. One thought is that you could add a dialog to the "Connect to an existing kernel" dialog asking for an optional "Remote path". If the user populates this field, you could use this as the basis for the runfile path and debug file path, Maybe down the road it could be added to File->Open, File->Save etc, but I imagine this would be a lot more work.

sohomb91 commented 4 months ago

+1 Still definitely a plus towards this enhancement! Do we have an idea, if its still being considered?