hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

The command line argument "{connection_file}" isn't replaced correctly

Open ed9w2in6 opened this issue 4 years ago • 3 comments

Prerequisites

Description

I have downloaded a external Jupyter kernel from the official list. It is the tslab kernel

So the issue is hydrogen is not correctly replacing the text {connection_file} with the path to the connection file just because it is not a single argument by itself.

The correct behaviour of jupyter_client on argv should be, quote:

argv: A list of command line arguments used to start the kernel. The text {connection_file} in any argument will be replaced with the path to the connection file.

This is quoted from the jupyter_client documentation.

And indeed, jupyter notebook did correctly replace the {connection_file} despite it not being a stand-alone argument but rather a part of an argument string. And that kernel works completely fine in jupyter notebook.

Note that tslab is not necessary to produce the said error. It is actually harder to spot if this happens to ipykernel as it does not complains, but rather just not responding.

Here is the step to reproduce that in using only ipykernel:

Steps to Reproduce

This assumes a *nix / linux OS and environment.

  1. At shell, do jupyter kernelspec list. You should see something like this:
Available kernels:
  kernelA      /path/to/kernelspec
  kernelB      /path/to/kernelspec
  python3    /path/to/kernelspec
  1. Change directory to the path to the kernel spec for python, or simply open that folder with a file manager.
  2. At that directory, open the kernel.json file, it should originally be something like this:
{
 "argv": [
  "/path/to/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}
  1. Edit and save the file to something like this, ( change the path to your installation path of python )
{
 "argv": [
  "/path/to/python",
  "-m",
  "ipykernel_launcher",
  "-f={connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}
  1. do jupyter notebook, create a new python notebook, run 1+1, it should work fine.
  2. do the same at atom, create a new python file, run 1+1, there should be no response.

Clean up Revert changes to the kernel.json file to fix the issue. do kill $(pgrep python -m ipykernel_launcher) as the non-responsive ipykernel is actually still running.

Versions

OS version: MacOS 10.15.6(19G73)

atom --version

Atom    : 1.48.0
Electron: 5.0.13
Chrome  : 73.0.3683.121
Node    : 12.0.0

apm --version

apm  2.5.0
npm  6.14.5
node 10.20.1 x64
atom 1.48.0
python 3.7.6
git 2.24.3

Hydrogen version:

Hydrogen version: 2.14.4

Plugins

Have you installed and activated any of the Hydrogen plugins below ? NO

  • [ ] hydrogen-python
  • [ ] Hydrogen Launcher
  • [ ] Data Explorer

Logs

[Please post any error logs and the output of the developer tools as described in our Debugging Guide.]

Exception trace for tslab

UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '{connection_file}' 
at Object.openSync (fs.js:465:3) 
at Object.readFileSync (fs.js:368:35) 
at ZmqServer.init (/usr/local/lib/node_modules/tslab/dist/jupyter.js:411:47) 
at startKernel (/usr/local/lib/node_modules/tslab/dist/main.js:101:12) 
at Command. (/usr/local/lib/node_modules/tslab/dist/main.js:165:9) 
at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/tslab/node_modules/commander/index.js:413:31) 
at Command._parseCommand (/usr/local/lib/node_modules/tslab/node_modules/commander/index.js:914:14) 
at Command._dispatchSubcommand (/usr/local/lib/node_modules/tslab/node_modules/commander/index.js:865:18) 
at Command._parseCommand (/usr/local/lib/node_modules/tslab/node_modules/commander/index.js:882:12) 
at Command.parse (/usr/local/lib/node_modules/tslab/node_modules/commander/index.js:717:10) 
{ errno: -2, syscall: 'open', code: 'ENOENT', path: '{connection_file}' }

Expected behavior

Replacing the text {connection_file} in any argument at argv in the kernel's kernel.json the path to the connection file.

Screenshots

Not Applicable.

Additional context

The tslab kernel works correctly with Jupyter notebook, but node.js complains about not having a file called '{connection_file}'

Please see the Logs section for the exception trace.

So I looked into the kernel.json file for that kernel and this is how it looked

{
 "argv": [
   "tslab", 
   "kernel", 
   "--config-path={connection_file}",
   "--js"
  ], 
  "display_name": "JavaScript", 
  "language": "javascript"
}

It is then I realised the issue with the help of the jupyter_client documentation.

ed9w2in6 avatar Aug 08 '20 00:08 ed9w2in6

I reckon this definitely should be changed as the jupyter_client documentation explicitly says: "the text {connection_file} in any argument will be replaced with the path to the connection file."

That is, if hydrogen would like to behaves as close the Jupyter client as possible.

ed9w2in6 avatar Aug 08 '20 00:08 ed9w2in6

sorry, but the bug still exists. Would you fix it? please m(_ _)m

Versions

OS version: win10 1909

atom --version

Atom    : 1.51.0
Electron: 5.0.13
Chrome  : 73.0.3683.121
Node    : 12.0.0

apm --version

apm  2.5.0
npm  6.14.5
node 10.20.1 x64
atom 1.49.0
python 3.8.2
git 2.28.0.windows.1
visual studio 2015

Hydrogen version:

Hydrogen version: 2.14.5

Logs

[Please post any error logs and the output of the developer tools as described in our Debugging Guide.]

Exception trace for tslab

UnhandledPromiseRejection: Error: ENOENT: 
no such file or directory, open '{connection_file}' at Object.openSync (fs.js:466:3) at Object.readFileSync (fs.js:369:35) at ZmqServer.init 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\jupyter.js:411:47) at startKernel 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\main.js:101:12) at Command. 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\main.js:165:9) at Command.listener [as _actionHandler] 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:413:31) at Command._parseCommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:914:14) at Command._dispatchSubcommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:865:18) at Command._parseCommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:882:12) at Command.parse 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:717:10) { errno: -4058, syscall: 'open', code: 'ENOENT', path: '{connection_file}' }

we684123 avatar Sep 28 '20 18:09 we684123

Is this fixed yet?

ed9w2in6 avatar Nov 24 '20 11:11 ed9w2in6