[IPython-dev] Thoughts on the notebook format for version control
Sat Nov 5 22:14:41 CDT 2011
Shall I push the sort_keys to master? It's a one-line change in
diff --git a/IPython/nbformat/v2/nbjson.py b/IPython/nbformat/v2/nbjson.py
index b86297d..e67bec3 100644
@@ -48,6 +48,7 @@ class JSONWriter(NotebookWriter):
def writes(self, nb, **kwargs):
kwargs['cls'] = BytesEncoder
kwargs['indent'] = 4
+ kwargs['sort_keys'] = True
return json.dumps(nb, **kwargs)
Since loading from JSON is not sensitive to ordering, this can't have any
effect on the content of existing notebooks, other than a reorder of keys
in the file the first time it is saved.
On Sat, Nov 5, 2011 at 20:08, MinRK <firstname.lastname@example.org> wrote:
> On Sat, Nov 5, 2011 at 19:58, Fernando Perez <email@example.com> wrote:
>> On Sat, Nov 5, 2011 at 7:41 PM, MinRK <firstname.lastname@example.org> wrote:
>> > On Sat, Nov 5, 2011 at 18:58, Fernando Perez <email@example.com>
>> > There is a *huge* disadvantage in portability to notebooks not being
>> > files. I think this still makes
>> > sense, though. I would treat the output as a 'cache' (along the lines
>> > .pyc / __cache__),
>> > rather than considering the notebook itself as a multi-file format.
>> And you
>> > should be able
>> > to embed the outputs in a single file if you want, for easier
>> > Doing it this way would not require changing the notebook format,
>> > current (output-included)
>> > notebooks would still comply with the spec.
>> I agree that it's a big inconvenience for everyday, non-VC use. I
>> like the idea of making it optional, it can be a flag set in the
>> metadata dict, that indicates whether to keep outputs in the cache or
>> internally (and also to offer the single-file download option).
>> > I think this sounds like a good start, with the only change that we
>> > allow (optionally) outputs in a single file via the download button,
>> > than the notebook format being canonically multifile, which is just too
>> > painful.
>> Yes, that sounds like a good balance between everyday usability and
>> being VC-friendly.
>> > I think the key-order issue you mention in the addendum is easily fixed
>> > specifying `sort_keys=True` in the json dump.
>> That's great to hear, I thought we'd have to do the sorting manually.
>> That's a change we should make right away then, since it doesn't
>> change the format. People can manually remove outputs from their
>> notebooks and this will help if they use VC a little bit (even if the
>> singe-line cells issue isn't fixed yet).
> Yes, and if I recall, for now you can just hit 'ClearAll outputs' prior to
> save/commit, to remove output from VCS.
>> Thanks for the feedback!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev