-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Are double percent scripts of Jupytext compatible with that of Spyder? #7933
Comments
Well, we introduced that practice, i.e. we were the first ones to define cells with
At the moment we can't process markdown and I don't think we could in the future. That's because we're really oriented to evaluate plain text files. However, the cell metadata stuff looks interesting. Pinging @bcolsen about this, who has been working with cells a lot lately. How do you use and handle cell metadata in Jupytext? It's not that clear from the spec. And thanks a lot for reaching out to us! |
Thanks @ccordoba12 , that's an interesting feedback. It's good to know that the
with Jupytext offers no option to render or execute the text notebooks, but it can convert them to Jupyter notebooks (or to R markdown), which can then be executed and exported to HTML, PDF, etc. That is the point of having support for markdown cells, and cell metadata (taken verbatim from Jupyter, converted to matching knitr options when converting to R markdown). I am not sure I am aware of what Spyder can do with these cells in scripts. I've seen that I was able to run the cells one per one in the console. Is it possible to 'render' the scripts to HTML or some other format? Does spyder include any rendered like Any way, for now I think the most important questions are...
|
@mwouts Jupytext looks like a great way to integrate the spyder text editor with the notebook plugin! I haven't really used the jupyter notebook that much but I'll try to be helpful there, but I have spent a couple of hours writing and thinking about this so I hope it's helpful I might be missing some functionality that already exists in Spyder(@ccordoba12 ?)but it would be pretty cool to execute a text file and the output goes to the notebook plugin. Then running a cell in the text editor and have it only update that notebook cell. I my not sure what your plan is here with
Again it would better to be explicit here as well. My take on the format would look like this:
I looked at your examples in the issue you linked and it seems like Even though the order wouldn't matter, I'm suggesting name first for compatibility with existing editors that use the labels like Spyder does in the outline explorer. The editors will still likely take the whole line as the name but at least it will start with something user defined rather then seeing a bunch of As for the non-code cells I would suggest wrapping them in Spyder recently implemented grouped code cells with the |
Thanks @bcolsen , there are so many useful suggestions in your comments!
Another side remark... I just saw that Jupyter requires that |
I think each one should be a cell. They are really just there to help code organization, but it would be sweet if notebook actually had code cell groups. The only thing for Jupytext to worry about is to catch any number of
They likely do that so
Yeah this would be a Spyder thing. I think with the current syntax we are taking about we could actually get something similar to R markdown files for python files. |
Thanks @bcolsen for the useful comments. I have included a few of your suggestions above for the next format update at mwouts/jupytext#89 ! I'm not sure I would recomment to work on an alternative to R markdown for python files. I've seen a few previous attemps (pystich, knitpy), and I think a very hard work is required to achieve the same functionality as R markdown. Why not using either |
Exactly what i was thinking (and didn't say). Use jupytext to make a notebook from python, execute the notebook to get the results(this should be possible) and use nbconvert go from there to PDF or HTML. I would just make an |
Great! That's documented here. You can either execute the notebook on the command line, on in Python directly (in combination with |
@bcolsen, @ccordoba12, do you think I could map the Spyder cell title to the cell content in the Jupyter representation? Currently I map that to the 'title' cell metadata, but that's not very useful. Precisely, what would you think of converting
to
in the Jupyter notebook ? (and reversely, map the first comment of code cells to the cell title) |
I don't have a problem with that. |
By
You mean the title would be Also:
could be
with heading2: Basically:
I don't think there is more than 5 headings. |
Thanks @bcolsen , @ccordoba12 for your quick replies. Well, @bcolsen , the case of sub cells is interesting. In Python I think a line starting with two
Which one do you prefer? Also, more generally, I think there a subject, of defining the specifications for that format. Nteract has done an interesting job on making the format language agnostic in Hydrogen, and it looks very plausible that they will have to implement another parser (in javascript - they're not python based). I am afraid that, if we don't have clear and well accepted specs, we may end up with incompatible implementations, and that would be a pity, right? Do you have an idea on how we should proceed for that? Is there a natural autority for this (Python board? Jupyter?) |
I think I miss read your comment. I though you were talking about a markdown/html formatted header in the notebook above the cell not as a comment in the cell. For a comment in the actual code your suggestion would work but it would loose the sub cell information. I think actually leaving the cell name comment as is with the meta data and cell type striped would be the safest thing to do:
to
This way users can use whatever cell separators they want (as long as you have it in Jupytext) and it won't be lost. |
Just wondering what is the state of this @ccordoba12 :-p |
We don't have plans to implement this. @bcolsen, what do you think about it? |
I would say that this conversation has filled it purpose in that jupytext now supports Spyder style "percent" cells. The only other interesting idea in this thread would be integrating jupytext with the spyder-notebook plugin so a file in the Spyder editor could be opened in the notebook or a notebook could be opened in the editor. I don't use the notebook at all currently, but maybe @jitseniesen or a notebook user might be interested. It looks like jupytext does most of the heavy lifting and it's mostly a user interface thing. All that being said, maybe if we had this feature I might use the notebook more :-) |
Nice idea, I opened an issue in the notebook plugin. |
I do agree 100%. I think we're done with this question and that now, the Spyder format and the
Thank you @jitseniesen ! Indeed, it would be great to offer integration directly in Spyder, like is done in VIM with the jupytext.vim plugin: when the users open an |
I see that Spyder has the practice of identifying cells based on lines starting with `# %%'. As this seems to be a common practice (among Spyder, Hydrogen, VScode) I have just implemented, in Jupytext, a Jupyter notebook converter to double percent scripts, cf. mwouts/jupytext#59.
Could you please provide feedback on the format specifications? I found no mention of how markdown cells should be represented (or even cell metadata), so I had to made a few choices on my own, and I would like to make sure that these choices are fine with Spyder's practice as well.
If you also want to test the converter, then install jupytext RC with
and use the command line converter
The text was updated successfully, but these errors were encountered: