-
Notifications
You must be signed in to change notification settings - Fork 84
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
Infer MyST notebook files by looking for ```{code-cell} blocks #120
Comments
You don't need all of that though, just: jupytext:
text_representation:
format_name: myst
kernelspec:
display_name: Python 3
name: python3 Is that really that cumbersome? If not it would likely be way more time-consuming, because you then have to read through the entirety of every markdown file to check for |
Hmmm - I do worry that it is too much for people to remember. Here are the points of confusion that I can think of:
In the end I guess that most people will need to look up another myst-nb file locally or on the internet and then copy/paste the header information to make it work. That feels like unnecessary complexity to me. My guess is that most people would want a myst markdown file to behave the same way that a notebook works: you just "create the file" and don't have to worry about the details I think one way that we could get around this would be to have a short-hand for myst-nb, something simple like |
Well when you say "just create", you still have to install jupyter first, then open a new notebook within the editor you loaded by instantiating A CLI command would be the way; whereby you supply the file(s) to insert the metadata on, and it would give you the same option of available kernels as you get in jupyterlab/notebook. |
Could this be partly solved by a To me this seems more explicit and hence more informative. Even if you still need to specify the kernel, some of the confusion is removed. |
I think that ship has already sailed, using a different file extension was already ruled out #82 |
@chrisjsewell I wonder if this is something that could be added on the We could also easily add this just for MyST-markdown with the jupyter-book tool. Something like Also just to be clear - I think that for the MyST-NB repository, it is fine asking people to hand-type their own myst-markdown config. The people using that repo will be more developer types. I am more worried about Jupyter Book users, who are usually not developers and have lower tolerance for UX complexity edit: if I create a regular markdown file and run |
I'm worried about that too. I suppose it can be aleviated in the docs: recommended workflow is to edit notebooks in Jupyter. Use jupytext if you wish to work with text based source files. This is helpful if you want to use version control...etc. Not that many people read documentation. Most will look to examples. And that's a disadvantage of the QE example, now I think about it --- the source files are all myst-nb. Perhaps we need another where the source files are just ipynbs. |
Yeh by all means raise an issue in jupytext for this
Yeh maybe something like that. Obviously it should be noted here that this is only an issue if you are directly creating the markdown file. If you are converting from a notebook |
yeah for sure - I have just found a few times now I just wanna start writing a new markdown file from scratch that has a notebook structure, and have gotten tripped up a few times needing to find some YAML header boilerplate to copy from another file |
I asked around in jupytext, and the answer is here: it's basically
so maybe we add a little CLI command like
or
and it initializes a myst file with the jupytext header using a default jupyter kernel. WDYT? I think that'd make it more discoverable than asking people to remember the jupytext invocation. |
Sounds good
I think it would be good to prompt the user for which kernel to use (using the code from |
Do you think as a first step that we could just tell people what kernel was used by adding an output message like:
and if it became a point of confusion for users (e.g. if we got issues like "why doesn't my myst kernel work?!") then we could consider making it a forced choice by the users? |
No I think its best to just add it straight away, otherwise it will never get done, just something dead simple like: $ jupyter-book myst-init --kernel python2 a*.md
$ jupyter-book myst-init b*.md
Available kernels:
1) python2 //anaconda/share/jupyter/kernels/python2
2) python3 //anaconda/share/jupyter/kernels/python3
Please select a kernel [1]? Note that nbformat fails validation if you don't set both |
I think this might raise some confusion in people (in my experience the large majority of Jupyter users, and the vast majority of newer users, have no concept of "multiple kernels"...they just "start jupyter with python"). And in many cases where kernels are registered programmatically, it causes more confusion than not. E.g. here's my kernel spec output: $ jupyter kernelspec list
Available kernels:
python38064bitdevconda4b8a6e5722f543c58b1e2eb07ef73d17 /home/choldgraf/.local/share/jupyter/kernels/python38064bitdevconda4b8a6e5722f543c58b1e2eb07ef73d17
python3 /home/choldgraf/anaconda/envs/dev/share/jupyter/kernels/python3 (I suspect that the first one is registered by vscode but I don't actually know where it came from) If I have no mental model of environments, kernels, etc (which most Jupyter users do not, I would guess), I don't really know what to do about those two options. I'm worried that this confusion will then arise in the form of support questions etc in our repositories... So I guess my thinking can be summarized as:
But, I also recognize why you think this is a good idea...hmmm. If, considering what I said above, you still think we should get feedback about it, then I'll concede and we can build in a "kernel selector" step (maybe only do this if there's more than one kernel?). |
Yep, vscode-python registers ones per conda env |
and yes, if only one kernel was registered then this would be selected without asking |
I think the most-common ways to create new notebooks are: (though don't have data on that so I might be wrong). In both cases users just click "the python one" and don't necessarily need to know about kernels etc. but, that aside - OK let's compromise on the following:
Sound good? Any strong preferences between |
I've got some of this functionality now here: executablebooks/cli#97 It's not quite as sophisticated as having a fully-interactive thing, but I think is a good start. |
Closing this in preference to #214 |
I'm writing up the documentation on MyST notebooks in the CLI, and I found that it is a bit cumbersome to ask users to explicitly create Jupytext headers for their MyST notebooks. It's easy if you're using Jupytext, but if somebody wanted to create a MyST notebook from scratch, they won't be able to remember:
Could we add an extra check here: https://github.com/ExecutableBookProject/MyST-NB/blob/0919b71ab5efc33823007bc2d92d64a8c7d217da/myst_nb/converter.py#L46
such that if no
jupytext:
block was found in the metadata, it scanned the lines for one that began with```{code-cell}
and, if so, assumes that this is a myst-nb file? We could even raise a warning in this case saying "I'm inferring that this is a myst notebook, you should explicitly make it so by adding this YAML metadata"The text was updated successfully, but these errors were encountered: