-
Notifications
You must be signed in to change notification settings - Fork 4
Eagerly add kernel metadata before the kernel is initialised #192
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
Eagerly add kernel metadata before the kernel is initialised #192
Conversation
IMO this is a bug on the CKHub side - the specification lists these fields as optional, which is why xeus-r kernel for example does not populate them. It should be solved in CKHub. I reported it previously JupyterEverywhere/sharing-service#9 and it ought to be solved by JupyterEverywhere/sharing-service@79d8f14 - I just wonder if it was not solved across the board, or were we facing the issues due to old CKHub deployment? |
|
Also, |
Thanks for the links! Yes, on Friday, I somehow managed to figure out this bug independently of you, haha (see the internal Slack thread with @adamblake). The
The error message is this: |
Oh, I see that you've seen the thread too and responded there – never mind, thanks! |
|
These are what look like the offending lines: https://github.com/JupyterEverywhere/sharing-service/blob/627cf993a69d4acf863fa56d16ddc037079c3fe1/src/main/java/org/jupytereverywhere/model/JupyterNotebookEntity.java#L36-L40 |
My point is that it is a bit arbitrary. The https://nbformat.readthedocs.io/en/latest/format_description.html#top-level-structure
If CKHub wants to be different (and if there is a good reason for it), then it should be documented somewhere outside of the codebase, otherwise issues like this will continue propping up. |
|
Okay, that is much clearer. I think we should either keep this a draft for now and revisit it when it is handled from the backend, or go ahead with this and ask to start versioning the sharing service, as it would be good for reliability and for being able to know what changed. |
Co-Authored-By: Michał Krassowski <[email protected]>
This reverts commit a8f02f7.
peytondmurray
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment I'm not in favor of merging this, not because of any issue with what's here but because if CKHub doesn't conform to the notebook spec (i.e. it doesn't follow nbformat) it's a CKHub problem and should be solved there. In fact, making a workaround here may result in a fix being deprioritized there.
Practically speaking it if it breaks the webapp people will report it here, and if it takes too long to get things solved with CKHub we can accommodate here, but I'd really prefer not to. Let's therefore wait for the moment on this change and instead continue to encourage CKHub to get this fixed.
| (kernelFromUrl as 'xpython' | 'xr' | undefined) ?? | ||
| 'xpython'; | ||
|
|
||
| const language: 'python' | 'r' = KERNEL_NAME_TO_URL[kernelName] as 'python' | 'r'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, typescript literal types can be cumbersome. If we end up merging this at some point, can we define KernelName and KernelLanguage literal types? e.g.
type KernelName = 'xpython' | 'xr';
type KernelLanguage = 'python' | 'r';Then you can change KERNEL_NAME_TO_URL to use that type, and the line above becomes
const language: KernelLanguage = KERNEL_NAME_TO_URL[kernelName];(with no need to cast).
|
I'm going to move this back into draft since we are waiting on CKHub for a fix. |
|
This PR should no longer be required, as the issue has been fixed upstream: JupyterEverywhere/sharing-service#24. I'm closing this! |

This PR addresses the problem discussed with @ivonnem3 and @adamblake internally where we were receiving the HTTP 422 error code from the sharing service if we try to save/share the notebook before the Python/R kernels are initialised. I've added an
ensureLanguageMetadatafunction that adds three fields if needed: the kernel language info (required to resolve the HTTP 422 error code), and the language info'sfile_extensionandversionto fix a further HTTP 500 error code.I have not added a test for this change at this time; it is difficult to test it in its current state because we currently mock the API calls for the sharing service and #73 is not yet resolved. I've verified this manually by spinning up the sharing service locally and ensuring that the save and the share buttons generate a shareable URL before the kernel is loaded.