[IPython-User] add new metadata in the current notebook

epi massimodisasha@gmail....
Tue Mar 5 15:14:34 CST 2013

Thanks Matthias,

sorry for the late response to the topic.
i'll look fwd to see any changes on that direction.

what i was looking for is a way to build a "custom form" that is connected with the full notebook (not all the cells)
in order to allow the user to fill that form and store the metadata into the notebook.

the idea is to generate that form reading a sort of configuration file, so it can be customized based on different use cases.

Maybe of interest to others here, the reason why i'm doing this is to have some "hidden metadata" to collect the "provenance" of a specific workflow following the W3C standard ( prov-dm [1] or prov-o [2] ) 

in the main time i'm studying the w3c standards … i have to work on a list of possible metadata tags that i need to embed in the notebook for my specific use case.

i'll let you know how it goes (i'm studying the raw input function)



[1] http://www.w3.org/TR/prov-dm/ 
[2] http://www.w3.org/TR/prov-o/

Il giorno 23/feb/2013, alle ore 05:18, Matthias BUSSONNIER <bussonniermatthias@gmail.com> ha scritto:

> Hi Massimo, 
> Le 23 févr. 2013 à 03:03, epi a écrit :
>> i was looking for a way to add new "hidden metadata" such as "author" , "date", "description" .. others in the "current notebook" (e.g. during a notebook session)
> Yes, this is something we want to add. We will first finish moving to bootstrap before writing the UI for that. 
> Al also planned on adding "license" and stuff like that and make it available in nbconvert/viewer.
> ANd it is one of the things that are annoying me right now and that I would like to have. 
> The "author" will more probably be "authors" and be a list of dict with fields like 
> name, email, github_handle, adress... etc we have to think carefully of the structure.
> Metadata would also store things like the main language of the notebook (it won't by only python forever !) 
> An IPEP would be welcomed with proposal of data structure. 
>> def addNbTag(key, val):    
>>   # add the new tag in the current notebook
>>   # and save it 
>>   # nbdir =  check the notebook.dir
>>   # nbname = check the current notebook name
>>   # nb = nbdir/nbname
>>   # nb[u'metadata'][u'key'] = 'val'
>>   # save the notebook embedding the new metadata
> The way to do it is most probably not in python, but with javascript using custom.js if you want to do it in 'current session'.
> I would suggest looking at 
> https://github.com/ipython/ipython/blob/master/IPython/frontend/html/notebook/static/js/celltoolbarpresets/default.js#L21
> That provide a "raw edit" button for metadata on the per-cell basis.
> That would require writing Json by hand for now. 
> Also, if you go this way now I would suggest you put the metadata in a sub key to avoid future conflict. 
>> addNbTag(u''author',u'epi')
>> in order to be able to do in python  :
>> from IPython.nbformat import current
>> f = open('file.ipynb','r')
>> s = f.read()
>> nb = current.reads(s, u'json')
>> nb[u'metadata'][u'author']
> Yes, this would be the right way to do it, maybe with get() to avoid non existing keys...
> -- 
> Matthias
>> Have you any suggestion ?
>> Thanks,
>> MAssimo.
>> _______________________________________________
>> IPython-User mailing list
>> IPython-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-user
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user

More information about the IPython-User mailing list