martin-saurer / jkernel

Jupyter Notebook / J Integration
GNU General Public License v3.0
44 stars 15 forks source link

Possible bugs in Jkernel #17

Closed marvin-littlewood closed 8 months ago

marvin-littlewood commented 3 years ago

Thank you for an excellent JKernel. I have really enjoyed creating my first J notebook.

I am using a fully updated miniconda3 and conda-forge jupyter lab on Ubuntu 20.04 running on Windows 10 in the WSL2 environment.

I noticed 4 issues for most of which there are work-arounds - involving a certain amount of extra effort - but which I report here for your consideration. They are:

  1. there is no syntax highlighting for J in the editor but there is when the document is exported as HTML.
  2. the images produced by plot are all a fixed size.
  3. I cannot export the text as an executable script because of the following error:
nbconvert failed: FileExtension trait 'file_extension' does not begin with a dot: 'ijs'
  1. errors of the following type appear in the console:
[I 2021-08-21 14:54:03.135 ServerApp] Saving file at /Documents/iTeachJ/1.1.Computation.ipynb
[E 2021-08-21 14:54:03.356 ServerApp] Notebook JSON is invalid: Additional properties are not allowed ('source' was unexpected)

    Failed validating 'additionalProperties' in display_data:

    On instance['cells'][85]['outputs'][0]:
    {'data': {'text/html': '<!DOCTYPE html>\n'
                           '<html lang="en">\n'
                           '<head>\n'
                           '\t<meta charset=utf-8>\n'
                           '\t<...'},
     'metadata': {},
     'output_type': 'display_data',
     'source': 'J'}

Thank you very much indeed in advance for any fixes.

marvin-littlewood commented 3 years ago

On a Mac (Catalina) the plots do not show at all with the latest Jupyter Lab but on the plus side, the above errors about: 'Notebook JSON is invalid' don't appear!

martin-saurer commented 3 years ago

I just tried it with J902, latest Anaconda, on MacOS 10.13.6 (last compatible release on my (very) old MacBook Air). Plotting seems to work fine. There are some problems with viewmat. I will investigate, as soon as time permits.

marvin-littlewood commented 2 years ago

Thank you for taking notice. I am a bit of a J novice but want to encourage my maths degree students to explore the language next academic year, so I am grateful for any help you can give. Your result with High Sierra and Anaconda is interesting and shows a marked difference from Catalina (10.15.7). I am using a fully updated version of Jupyter obtained via a fully updated Miniconda. Whether this helps much will not be clear until I can run a debug environment. Please can you point me in the direction of how you tested the kernel on the Mac? I am willing to try to help find a diagnosis. Many thanks.

martin-saurer commented 2 years ago

During testing I got the error 4. of your initial post (additionalProperties) for the first time. Never saw that before. There is some strange behavior on MacOS. I have to investigate further. Debugging of the jkernel is done via the Python print() function in jkernel.py. So no special debugging environment. I‘ll let you know as soon as I have some news on this issue.

martin-saurer commented 2 years ago
  1. there is no syntax highlighting for J in the editor but there is when the document is exported as HTML. => Cannot reproduce

  2. the images produced by plot are all a fixed size. => needs further investigation

  3. I cannot export the text as an executable script because of the following error: => fixed in latest release

  4. errors of the following type appear in the console: => Should be fixed in latest version (can no longer reproduce)

I cannot reproduce the plot problems on Mac. Did you had a chance to investigate further?

martin-saurer commented 2 years ago

Regarding Problem 2: Define the size of the plot with the following J command: plotdef 'jijx';'plot'; Where: = width = height Example: plotdef 'jijx';'plot';800 600 All subsequent plots will have a size of 800 x 600

martin-saurer commented 2 years ago

Regarding Problem 1: Syntax coloring seems to be ignored in Jupyter Lab only. Jupyter Notebook works fine. It seems the jkernel needs to be rewritten to be a full Jupyter Lab extension. I will take a look at it, as soon as time permits. Volunteers welcome ;-)

marvin-littlewood commented 2 years ago

I did a git pull to new tag 3.2.4 and found the following:

  1. there is no syntax highlighting for J in the editor but there is when the document is exported as HTML. => Cannot reproduce ==> works in a notebook which is fine

  2. the images produced by plot are all a fixed size. => needs further investigation ==> using plotdef 'jijx';'plot';800 600 works fine

  3. I cannot export the text as an executable script because of the following error: => fixed in latest release ==> the error recurs in a notebook and a lab.

  4. errors of the following type appear in the console: => Should be fixed in latest version (can no longer reproduce) ==> works fine in a notebook but similar errors still occur in a lab

I will be able to look into the issues around creating a Jupyter Lab extension after 31/5/22. In the meantime, using a notebook works fine and I can extract the script from a markdown file.

Very many thanks for spending time on this. Happy New Year!

PS: I investigated further on my Mac but didn't get anywhere. Sadly this will have to wait for a while.

martin-saurer commented 2 years ago

Many thanks for the feedback, and wish you also a happy new year!

I will keep an eye on it when my time permits (time is the difficult part of the story ;-)

Another contributor has begun to rewrite the J kernel, and tries to create a proper Python package hosted on PyPi. I will also have an eye on the progress of that project.

marvin-littlewood commented 2 years ago

The 3.2.4 update does correctly export to ijs. I had forgotten to alter the metadata of an already created notebook. Your kernel now works well enough for my purposes so many thanks again.

marvin-littlewood commented 2 years ago

I think I have solved issues 1 & 4 by the simple expedient of removing source: 'J' wherever it is mentioned (this message response entry has been removed in the latest version - 5.1) and by changing the mime-type to text/ijs and making consistent use of it in jkernel.py and syntax/J.js. I attach a git diff jkernel-changes.txt which I hope shows the changes.

I will do some more testing to see if the changes hold up after further use. I will also investigate further on my Mac to see what helps there. Apart from these configuration changes, it looks like your implementation of jkernel.py and jinter.py are fine for lab and notebook environments.

FWIW When I use Visual Studio code connected to the miniconda environment I created to use the J kernel, everything also works, except that I have to change the code boxes to 'plaintext'. I am not sure what causes this yet but the kernel also works there.

martin-saurer commented 2 years ago

Many thanks! I have applied the changes, but no luck with syntax coloring in CodeMirror of Jupyter Lab.

martin-saurer commented 8 months ago

No longer relevant.