Run Spyder /Python on remote server
Asked Answered
B

2

20

So there are variants of this question - but none quite hit the nail on the head.

I want to run spyder and do interactive analysis on a server. I have two servers , neither have spyder. They both have python (linux server) but I dont have sudo rights to install packages I need.

In short the use case is: open spyder on local machine. Do something (need help here) to use the servers computation power , and then return results to local machine.

Update:

I have updated python with my packages on one server. Now to figure out the kernel name and link to spyder. Leaving previous version of question up, as that is still useful.

The docker process is a little intimidating as does paramiko. What are my options?

Bahia answered 11/9, 2018 at 20:9 Comment(0)
J
25

(Spyder maintainer here) What you need to do is to create an Spyder kernel in your remote server and connect through SSH to it. That's the only facility we provide to do what you want.

You can find the precise instructions to do that in our docs.

Jurat answered 18/9, 2018 at 17:25 Comment(4)
Also remember to get VPN access ...arrgh.Bahia
does that work when you need VPN access on the top of the SSH connection? I mean, I my case I need to (I) start the VPN connection then (II) connect via SSH. Then I wanted to setup the Spyder kernel i.e. after (I) connecting via VPN then (II) SSH.Chickaree
No, it doesn't, sorry.Jurat
As I see now, I can use the ipython console in spyder using the remote kernel. But is there ways to use the variable explorer in Spyder, to see the variables that we used in the ipython kernel? And... Are there ways to create and run files in the remote through spyder client? Regardless, thank you for introducing this.Guanabana
O
1

I did a long search for something like this in my past job, when we wanted to quickly iterate on code which had to run across many workers in a cluster. All the commercial and open source task-queue projects that I found were based on running fixed code with arbitrary inputs, rather than running arbitrary code.

I'd also be interested to see if there's something out there that I missed. But in my case, I ended up building my own solution (unfortunately not open source).

My solution was:

1) I made a Redis queue where each task consisted of a zip file with a bash setup script (for pip installs, etc), a "payload" Python script to run, and a pickle file with input data.

2) The "payload" Python script would read in the pickle file or other files contained in the zip file. It would output a file named output.zip.

3) The task worker was a Python script (running on the remote machine, listening to the Redis queue) that would would unzip the file, run the bash setup script, then run the Python script. When the script exited, the worker would upload output.zip.

There were various optimizations, like the worker wouldn't run the same bash setup script twice in a row (it remembered the SHA1 hash of the most recent setup script). So, anyway, in the worst case you could do that. It was a week or two of work to setup.

Edit:

A second (much more manual) option, if you just need to run on one remote machine, is to use sshfs to mount the remote filesystem locally, so you can quickly edit the files in Spyder. Then keep an ssh window open to the remote machine, and run Python from the command line to test-run the scripts on that machine. (That's my standard setup for developing Raspberry Pi programs.)

Odo answered 11/9, 2018 at 22:33 Comment(2)
I've also worked in this kind of distributed dev space and the pattern we tended to land on was dev code on NAS/NFS mounted on your dev host with IDE of choice. The cluster workers either were user specific and had your repo as the PYTHONPATH or the user context (code path) was passed to the worker on submit (think spark or dask). For workers that were python and long lived, there was a bounce option to reload framework code that had changed. Some patterns involved some central db and a simple scheduler but those details were less important.Typology
Thank you for introducing sshfs. Although that doesn't help much for this problem, helped me with other problems I have been having with server connections.Guanabana

© 2022 - 2024 — McMap. All rights reserved.