Skip to content
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

information on current notebook filename? #25

Open
jhconning opened this issue Jan 25, 2017 · 4 comments
Open

information on current notebook filename? #25

jhconning opened this issue Jan 25, 2017 · 4 comments

Comments

@jhconning
Copy link

jhconning commented Jan 25, 2017

Does watermark include an option to include the notebook filename in the watermark magic output? I could not find such an option in the documentation.

If this is not currently possible, it would be an extremely useful feature to add.

By default a notebook printed out using the _File _PrintPreview option does not print the filename in the header or footer. I was looking at printouts from a couple weeks ago and watermark provides details about the hardware/software environment and date/time printed, but no an answer to the all important question of the name of the notebook, to know what file to return to.

From this stackoverflow discussion there seem to be ways to have the filename printed in a cell but none of the proposed solutions are compact or elegant. So it would be great if watermark could do the work behind the scenes.

Thanks for a great tool that I use daily.

**update: ** the jupyter notebook contributors appear to be discussing a similar issue jupyter/notebook#1000

@rasbt
Copy link
Owner

rasbt commented Jan 26, 2017

Thanks for the suggestion, it sounds useful to me. Yeah, something like this:

import os
from IPython.core.display import Javascript
from IPython.display import display

display(Javascript('Jupyter.notebook.kernel.execute(\
                       "this_notebook = " + "\'"\
                       +Jupyter.notebook.notebook_name+"\'");'))

os.path.abspath(this_notebook)

would work. Not sure how robust it is, but I can add it to watermark.

@jhconning
Copy link
Author

Thanks, looking forward to it. It is a feature that would make this already essential extension ...indispensable.

@rasbt
Copy link
Owner

rasbt commented Jan 27, 2017

Yeah, I will probably find it useful myself sometimes (I usually have too many jupyter notebooks open all at once, and this could quickly tell me where they are located ;)). Shouldn't be complicated to add, will try to get to it in the next few days!

@rasbt
Copy link
Owner

rasbt commented Feb 1, 2017

Hm, tried the workaround proposed in jupyter/notebook#1000, but it doesn't worked when I moved to the module (due to the different namespace as mentioned in the thread). I guess the only thing we can do now is to wait until some attribute with file path information gets added to Jupyter notebook or so. I will leave this open to come back to it with a solution some day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants