Spyder: Edit a file locally and run it remotely, is it possible?

Created on 24 Oct 2016  路  15Comments  路  Source: spyder-ide/spyder

I am working with Spyder 3.0.0b5 (Winpython 2016-04 ) in Windows 10 Environment.
I have Python 3.5.2.2 in the local machine (Winpython 2016-04 ) and Python 3.4.2 in a remote machine [ a EV3 brick with ev3dev (based in linux Debian)]

I am connected with success. ipython kernel, upload the json file, connect to existing kernel with "this is a remote kernel", etc...

However, when i try to run the script i get
ERROR: File 'XXXXXX' not found.

The problem seems clear.
The script is edited in the local machine and it only exist in the local machine. Does not exist in the remote machine (-ev3dev-). So when i run, the script is not found.

This problem is documented in:
https://github.com/spyder-ide/spyder/issues/3065

http://stackoverflow.com/questions/26699356/spyder-how-to-edit-a-python-script-locally-and-execute-it-on-a-remote-kernel

Any news about this? Any relevant info?
This problem is resolved in the last version 3.0.1?

Thank you very much!

DJuego

Editor IPython Console Enhancement

Most helpful comment

This is an interesting use case. You can edit files locally and run them in a remote kernel by creating a cell at the bottom of your file (i.e. a cell that contains your entire file) and the run that cell.

Something like this

from __future__ import print_function

print('Hello world!')

#%%

where #%% is the last line of your file. You can run that cell by pressing Ctrl+Enter.


We could also create some functionality to save files remotely, and then execute them with %run, but it's not clear to me how to do that :-)

All 15 comments

This is an interesting use case. You can edit files locally and run them in a remote kernel by creating a cell at the bottom of your file (i.e. a cell that contains your entire file) and the run that cell.

Something like this

from __future__ import print_function

print('Hello world!')

#%%

where #%% is the last line of your file. You can run that cell by pressing Ctrl+Enter.


We could also create some functionality to save files remotely, and then execute them with %run, but it's not clear to me how to do that :-)

Thank you for your swift answer, Carlos. Yes. I have used previously the method you describe. It works. Indeed, How can i stop the remote program manually?

I must admit I am a absolutely novice with python. Is it possible a remote debugging session with this approach and Spyder? How? Perhaps i have to use RPyC or Pyro4 for this purpose?

DJuego

P.S: Sorry for my English. I am Spanish. :-)

How can i stop the remote program manually?

That's the problem, you can't do that at the moment :-) That's a limitation of IPython/Jupyter, but there are some plans to fix it during the next year.

Is it possible a remote debugging session with this approach and Spyder?

Not right now, sorry.

P.S: Sorry for my English. I am Spanish. :-)

Don't worry about it, your English is perfectly fine ;-)

I am grateful for your honest answers. Thank you again, Carlos. 馃憤

_Keep calm and think another thing_ ;-P

DJuego

@DJuego, could you describe what you did to connect to a remote kernel on Linux from Windows on Issue #3323?

Several people say they are unable to do it :-)

Hi ,
Please help me to run my local code samp.py (which was present in my local windows) in Linux kernel which was host i connected through ssh.

Note: I need to run complete file.

Please help me in this issue.

This would be really good functionality if you guys at Spyder get it working.

For now I have connected to my remote server through Spyder by following this tutorial: https://medium.com/@mazzine.r/how-to-connect-your-spyder-ide-to-an-external-ipython-kernel-with-ssh-putty-tunnel-e1c679e44154

And have used the cells workaround that @ccordoba12 mentions above. Thanks guys!

Ping @nerohmot about this one.

Situation:

The first versions of spyder-remote are available, we are now able to start a spyder-kernel on a remote machine by the click of a button. :smile:

Now, from spyder we can execute a chunk of code from the editor to the remote-console by using the run current cell, but the run button is not able to execute bigger chunks (the current file, together with the current project) as the run button sends runfile('/home/nerohmot/Desktop/temp.py', wdir='/home/nerohmot/Desktop') to the current console (which happens to be a remote spyder-kernel) which would be fine if the remote system would have the local tree mirrored ...

Anyway we need to brainstorm on how this could be achieved.

Interesting library

Versions

  • Spyder version: >= 5.0.0
  • Python version: any
  • Qt version: N/A
  • PyQt version: N/A
  • Operating System name/version:

    • host : any

    • remote : Linux (Windows/macOS afterwards)

@ccordoba12 @goanpeca any ideas on this matter?
I think it is worth spending some time on this topic next Friday in the weekly.

Hi @nerohmot,

think it is worth spending some time on this topic next Friday in the weekly.

Sounds like a plan.

any ideas on this matter?

Edit a file locally and run it remotely, is it possible is a specific case of a more general problem that may include:

  • Being able to browse a remote file system of the Files plugin and the Projectsplugin and Global working directoryplugin.
  • Being able to change working directory based on that remote system
  • Open remote files on the editor and keep them in sync.
  • Have things work in sync.

Files

The current Files plugin is based on https://doc.qt.io/qt-5/qfilesystemmodel.html, so I believe that to handle it correctly a new RemoteSystemModel could be developed to handle the local and remote case. Some of the work started over a year in multiprojects already had a working implementation of a custom tree model with multiple nodes. That could be hooked to the actula information from the remote machine folder/file structure so it can be populated and browsed.

Interacting with remote files? What should the experience be when opening a remote file, as with FTP clients? it would get "downloaded" localy, and changes (saves///) would be mirrored remotely?

Projects

This would extend from the Files to the Projects plugin.

Now one workflow could be to have the Project explorer be local, but have awareness of a remote kernel and sync (rsync?) the project structure on the remote kernel, so the kernel can actually work on files n the remote system.

Consoles

The changes on projects will result in tracebacks that point to the remote file system, so some changes to be able to click and get the files opened on the local filesystem. Since the project would be mirrored and kept in synce, the local project base dir could be swaped by the remote project base dir

Global working directory

This plugin could be made aware of the remote filesystem, so that switching between consoles switched to the respective files system. This could do a similar thing for the Files plugin.

Edit a file locally and run it remotely, is it possible is a specific case of a more general problem

@goanpeca, this issue is only about running a local file in a remote kernel (which is what @nerohmot asked on issue #14085). For high level discussions on how to improve our remote functionality in general, please use issue #12827.

@nerohmot title was for projects as well, which touches consoles as well with the Spyder-remote work.

running code in a (remote) spyder-kernel in chunks bigger than a cell (file/project)

For projects it becomes more complex that the problem on this issue. That is why I added the different parts.

I need to digest this a bit (also need to read #12827), because indeed my simple 'sync' thing is maybe a little too simplistic :disappointed: anyway, keep on adding so we have a lot of ammo for Friday :+1:

we need to keep maybe sshfs in the back of our minds as an intermediate 'patch'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SapnaSM picture SapnaSM  路  3Comments

ok97465 picture ok97465  路  3Comments

danieltomasz picture danieltomasz  路  3Comments

cchu08 picture cchu08  路  3Comments

goanpeca picture goanpeca  路  3Comments