Open akhmerov opened 3 years ago
Right now we are reading the kernel name from the document metadata, like so:
The approach seems sound, however schema contains extra information.
// Options for requesting a kernel from the notebook server
kernelOptions: {
name: "python3",
kernelName: "python3",
path: "."
// notebook server configuration; not needed with binder
// serverSettings: <skipped>
},
I propose to use meta["thebe-kernel"]
as a passthrough dictionary with name
, kernelName
and path
. An alternative would be to consider string a special case, which then refers to name (or should it be kernelName?), however I think a direct passthrough is more reliable.
Quick thought on document metadata - we want this to work with notebooks that are read into sphinx (and have their metadata brought into the page). So we don't want thebe-specific metadata fields at the document level (unless it's for some functionality that is only specific to thebe)
Quick thought on document metadata - we want this to work with notebooks that are read into sphinx (and have their metadata brought into the page).
Wouldn't it be reasonable for the conversion tool to prepare these notebooks for thebe? Note how thebe needs more information than what the kernel knows about, namely path.
What conversion tool are you talking about?
I see several scenarios:
My point is mainly that thebe kernelOptions
isn't the same as notebook metadata that other tools define, and some information may be lost if we try infer kernelOptions
rather than provide another passthrough to thebe.
My feeling is that other tools shouldn't have to rework their own metadata just to work with thebe, if that metadata already exists. Instead we should try to infer it with thebe since it doesn't rely on us getting other packages to change their behavior - that seems harder to me. But maybe thebe-config can be a way to set it explicitly, and if this isn't set then we try to infer it from document metadata?
My feeling is that other tools shouldn't have to rework their own metadata just to work with thebe, if that metadata already exists.
I totally agree, but it wasn't actually clear to me whether this metadata already exists. Perhaps you can help me out here—below is what I found.
Overall we need to determine 3 configuration options:
// Options for requesting a kernel from the notebook server
kernelOptions: {
name: "python3",
kernelName: "python3",
path: "."
// ...
}
kernelName
Right now sphinx-thebe reads kernelName
from the doc metadata, and I believe this is where myst-nb places it. Is that correct?
Inferring the kernel name from the notebook metadata may face limitations down the line (https://github.com/executablebooks/thebe/issues/343), but it's certainly fine for now. If it was just this field, I'd be happy to leave this logic intact :heavy_check_mark:.
name
This one I don't actually understand. I see that thebe passes it to kernelManager
from @jupyterlab/services
, so it seems important, and different from kernelName
. What is this actually? Can we somehow infer it? Right now it's left blank. Is it because it's unimportant and can be ignored?
path
This is the location where the kernel needs to be started. It seems important since the notebooks may use external assets, and I can imagine this path being document-dependent. For me this is the main uncertain part. Is it safe enough to assume it's the doctree original path? Do we know how to reach it on binder?
I think that the most important is kernelName
and name
is not strictly required (but don't quote me on this). e.g., there's thebe docs that use kernelName
without name
.
for path
I actually do think we will need sphinx-specific information. We need to know the path to the Sphinx root, relative to the repository root (e.g., docs/
). Then we can use the page metadata to get the path to the page from the Sphinx root, and then create our own path
variable as <path-to-sphinx-root>/<path-to-page>
.
So I think we can infer kernelName
from the document metadata, and then create the path
field using an optional configuration variable along w/ the path to the page. Does that make sense?
hey @akhmerov - is this something you're interested in seeing through to the finish line? Another issue popped up (#38 that would be solved by this as well)
I will come back to this soonish™ (going through the beginning-of-semester pileup).
I think that the most important is
kernelName
andname
is not strictly required (but don't quote me on this). e.g., there's thebe docs that usekernelName
withoutname
.
I believe the thebe documentation is wrong here, see https://github.com/executablebooks/thebe/issues/349, https://github.com/executablebooks/sphinx-thebe/issues/59. Since thebe 0.6.0, the kernel is apparently spawned based on name
.
Closes #17, #24
So far this is an RFC. Does the overall idea seem reasonable, especially as far as removing of most defaults goes? I propose to remove those, so that the defaults can go to thebe repository directly.
TODO: