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

Errors when debugging with remote kernel #18330

Closed
shankyemcee opened this issue Jun 17, 2022 · 20 comments
Closed

Errors when debugging with remote kernel #18330

shankyemcee opened this issue Jun 17, 2022 · 20 comments

Comments

@shankyemcee
Copy link

Hi,

I am working on a similar problem as this post(#3587 (comment)) and all the comments are helpful. But for my use case I would like to debug my python script locally with a python kernel hosted on a cloud server, and I get similar issues:

This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was:

An exception has occurred, use %tb to see the full traceback.

OSError: [Errno 22] Invalid argument: '....'

For reference, I am using windows with spyder 5.3.1 and I am connecting to a remote linux kernel having python 3.7. The steps I followed to set it up using Mobaxterm:

login to your remote server, create your python environment there and start your python kernel using the following line:
python -m spyder_kernels.console --ip=127.0.0.1 -f=./remotemachine.json
(Note: ip address should can also be localhost)

Open another local terminal in mobaxterm and enter:
ssh -L ::<control-port from remotemachine.json @

Copy the generated remotemachine.json file to your local system, open spyder, click on connect to existing kernel:
enter the remotemachine.json path in Connection File,
in hostname put the ,
in username enter the for your cloud server,
in port put 22(default ssh port on mobaxterm),
and enter the password for remote server login.

And it should connect then. After these steps I am able to send simple command line functions, but not able to debug the file. Is there any new support added for this already?

Thanks.

@dalthviz
Copy link
Member

Hi @shankyemcee thank you for the feedback! I think this is not possible at the moment :/ but maybe @ccordoba12 or @impact27 could have some ideas?

@impact27
Copy link
Contributor

It should work now as you describe, but you have to make sure the version of spyder-kernels matches the version on spyder. I am working on a pr to use the control channel for debugging which should be more reliable, but because this won’t work with python 2.7, it won’t be available before spyder 6. Can you confirm the version on spyder you are using and the version of spyder-kernels on the remote server?

@shankyemcee
Copy link
Author

I am using spyder 5.3.1 on my system and spyder_kernels 2.3.1 on both the remote server and my own system. To me the error looks like its trying to look for the file in the remote system, but I am trying to debug it on my own system. Basically I just want to use the compute resources and packages on the remote server, but all file access and debugging should happen on my own system.

@impact27
Copy link
Contributor

Si the way it works is that spyder sends the content of the editor to the remote kerne. I’ll have a look to see if I can reproduce

@ccordoba12
Copy link
Member

ccordoba12 commented Jun 19, 2022

@shankyemcee, you posted above:

An exception has occurred, use %tb to see the full traceback.

Please run %tb in the IPython console and post the contents shown afterwards here so we can take a look at them.

@ccordoba12 ccordoba12 self-assigned this Jun 19, 2022
@shankyemcee
Copy link
Author

Output of %tb:

Traceback (most recent call last):

File "/project/6027213/shankar5/envs/lit/lib/python3.8/site-packages/spyder_kernels/customize/spydercustomize.py", line 512, in get_file_code
file_code = frontend_request(blocking=True).get_file_code(

File "/project/6027213/shankar5/envs/lit/lib/python3.8/site-packages/spyder_kernels/comms/commbase.py", line 557, in call
return self._comms_wrapper._get_call_return_value(

File "/project/6027213/shankar5/envs/lit/lib/python3.8/site-packages/spyder_kernels/comms/commbase.py", line 440, in _get_call_return_value
return self._sync_error(reply['value'])

File "/project/6027213/shankar5/envs/lit/lib/python3.8/site-packages/spyder_kernels/comms/commbase.py", line 496, in _sync_error
error_wrapper.raise_error()

File "/project/6027213/shankar5/envs/lit/lib/python3.8/site-packages/spyder_kernels/comms/commbase.py", line 90, in raise_error
raise self.etype(self)

OSError: [Errno 22] Invalid argument: '/project/6027213/shankar5/envs/lit/C:/Users/Dell G7 User 2/Documents/PROJECTS/vision_transformer/vision_transformer/vit_jax/main.py'

Here '/project/6027213/shankar5/envs/lit/' is where I hosted the remote kernel and 'C:/Users/Dell G7 User 2/Documents/PROJECTS/vision_transformer/vision_transformer/vit_jax/main.py' is the file on my system I am trying to debug

@impact27
Copy link
Contributor

impact27 commented Jun 20, 2022

When you press debug, what exactly appears in your console? do you have debugfile("/project/6027213/shankar5/envs/lit/C:/Users/Dell G7 User 2/Documents/PROJECTS/vision_transformer/vision_transformer/vit_jax/main.py", ...)?

@impact27
Copy link
Contributor

I have tried:

  • install spyder-kernels 2.3.1 on a remote machine
  • install spyder 5.3.1 on my machine
  • launch spyder-kernels with python3 -m spyder_kernels.console
  • copy the connection file at /home/debian/.local/share/jupyter/runtime
  • Connect on my local machine with "Connect to an existing kernel"
  • create a file on my desktop containing print(0) and a breakpoint
  • press debug on spyder

With that, the bebugging starts normally.

@impact27
Copy link
Contributor

I think I found it, it is a problem of windows vs linux paths:

IPdb [5]: os.path.abspath("C:/Users")
Out  [5]: '/home/debian/spyder-kernels/C:/Users'

@impact27
Copy link
Contributor

@shankyemcee Could you check if spyder-ide/spyder-kernels#389 solves the issue?

@ccordoba12 ccordoba12 added this to the v5.3.3 milestone Jun 20, 2022
@shankyemcee
Copy link
Author

shankyemcee commented Jun 21, 2022

Hi, Can I please know how I can access this update? Is it through updating spyder_kernels or spyder?

@impact27
Copy link
Contributor

On the remote machine:
git clone https://github.com/spyder-ide/spyder-kernels.git
cd spyder-kernels
git fetch origin pull/389/head:remote_path_fix
git checkout remote_path_fix
pip install .

@shankyemcee
Copy link
Author

Hi,
I followed your steps and re hosted the kernel from the remote server, but I am no longer able to connect my spyder ide to the Kernel on remote server.

@impact27
Copy link
Contributor

That is strange, could you give me the steps you follow to launch and connect, and the exact error you see?

@shankyemcee
Copy link
Author

Hi,

I refreshed the connections, and it appears to be working. But one problem is that I don't know which line is executing. For example here is the screenshot of when i used debugging with remote kernel:

remote_kernel

and here is a screenshot with debugging in local kernel:

image

The arrow is missing in remote kernel connection. Can this be added? Thanks.

@impact27
Copy link
Contributor

spyder-ide/spyder-kernels#389 has been updated, can you try again?

@shankyemcee
Copy link
Author

Thankyou, it's working brilliantly! Would this update be directly available through the next spyder_kernels release through conda or pip?

@impact27
Copy link
Contributor

Yes it should if we have time to merge it, otherwise the next one

@dalthviz dalthviz assigned impact27 and unassigned ccordoba12 Jun 23, 2022
@dalthviz dalthviz removed their assignment Jun 23, 2022
@dalthviz dalthviz modified the milestones: v5.3.3, v5.3.2 Jun 23, 2022
@shankyemcee
Copy link
Author

Sounds good, Thanks a lot for all your help!

@ccordoba12
Copy link
Member

We need this open so we don't forget to address it.

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

No branches or pull requests

4 participants