Version conversion, support for X to Y even if Y < X (nbformat)#4198
Conversation
|
FWIW, I started out thinking I was going to implement this in nbconvert but later changed my mind. Consequently my local branch is named |
There was a problem hiding this comment.
should be a relative import, I think
There was a problem hiding this comment.
I tried a relative import, and it did not like my syntax. Did you mean something like from .reader import X, Y, etc?
|
@minrk I think my code comment (above) may have flew under your radar. I ended up using |
There was a problem hiding this comment.
Neat trick, thanks for showing me that
|
With the changes you have here, what would be the code for something like "open a notebook file, give it to me in the current format, noting the original format"? |
nb = reader.read(...) # will load the file as is
(major, minor) = reader.get_version(nb) # will give you the version That way the steps are separate, which is what you suggested, right? Whoever reads the notebook is responsible for keeping track of the version if it matters. |
|
Sorry, by 'current version', I meant the latest version. That is, open the file, read it, upgrade it if necessary, note the original version. |
|
Ah, like this: nb = reader.read(...)
(major, minor) = reader.get_version(nb)
nb = convert.convert(nb, current.current_nbformat) |
|
Tests added and comments addressed |
There was a problem hiding this comment.
Just to display part of the JSON in the error message, that code came from current.py in master. Sorry it's kind of misleading since git has no way of tracking that I took those lines from that file.
See: https://github.com/ipython/ipython/blob/master/IPython/nbformat/current.py#L55
Just because it's in master doesn't mean it's the right behavior. It seems okay with me, do you think I should change it so it doesn't show any of the JSON?
There was a problem hiding this comment.
Then just a comment that say that 16 is "random". That the kind of things you can wonder when you came across that later, like, it might be to avoid new line, you might want `len('Notebook does not appear to be JSON:')+n < 80' to fit on terminal screen..
And for aestetic purpose add a '...' , I guess we can suppose we will never be in a case where the file is smaller than 16 char or empty.
|
Thanks all, comments addressed |
Also added a comment to explain why.
|
@Carreau I just addressed your comment about the print JSON error length. |
|
@ellisonbg do you want to have a look over this one to confirm that it's the way we want to go? Merging this is necessary to get started on the nbformat 4 work. |
|
Sure I will do that tomorrow... On Sun, Oct 27, 2013 at 3:00 PM, Min RK notifications@github.com wrote:
Brian E. Granger |
|
Detail when you will be working on nbformat v4, IJulia, IRuby, and soon IHaskell store |
|
OK I had a pretty close look at the core APIs in this PR. I think it looks good. I like the idea of having separate |
|
Okay, then merging away. Thanks! |
add upgrade / downgrade to nbformat
|
Woohoo! |
…vert add upgrade / downgrade to nbformat
This is an implementation that is done in nbformat. I'm still not convinced that the conversion shouldn't be done in nbconvert once the ipynb->ipynb stuff gets checked in.
TODO