choldgraf / nbclean

A collection of tools to preprocess, modify, and otherwise clean up Jupyter Notebooks
MIT License
64 stars 5 forks source link

content = True argument - is this removed #5

Closed lwasser closed 6 years ago

lwasser commented 6 years ago

Hey @choldgraf i just ran into an error with nbclean

Here is the code:

# Clean the notebook's content using tags
    cleaner = nbclean.NotebookCleaner(ntbk)
    cleaner.clear(content=True, stderr=True, tag='hide')
    ntbk = cleaner.ntbk

And the error

Traceback (most recent call last):
  File "scripts/generate_posts.py", line 113, in <module>
    cleaner.clear(content=True, stderr=True, tag='hide')
TypeError: clear() got an unexpected keyword argument 'content'

I suspect that content=True is no longer an argument for the .clear method based upon that error and this repo. BUT... in the docs here it does seem to be a valid argument. But in your repo it clearly is removed.

This script works fine on version .1 but .3.1 seems to have changed. before i make any code changes i just wanted to check with you about the state of nbclean and the arguments that it expects. thank you for any guidance. i may be missing something here too!!

Ok i just studied your code.

do i want kind = 'content' and then i'm not sure what the stderr argument in the original code does.
Also you have tag as a string. i suspect hide will still work. However just a question. What is we wanted to hide the output image rather than the content for some cells but not all. would you use different tags? the code appears to use the kind argument to determine what to hide which fixes the code to only hide one type of thing throughout the notebook? ie it will hide all images. or all content. but you may want to hide one cell's output image and another cell's content.

Just trying to understand how this works! thank you again :)

choldgraf commented 6 years ago

hey! sorry for the slow response, been in Kansas City for my wedding reception :-)

Thoughts below:

do i want kind = 'content'

yep, rather than having a bunch of XXX=True keywords, I thought it'd be easier to have a single kind=<string> keyword. See this line for the arguments it can take:

https://github.com/choldgraf/nbclean/blob/master/nbclean/clean.py#L29

What is we wanted to hide the output image rather than the content for some cells but not all. would you use different tags?

Yep, I think that'd be the way to go. Just use a tag like hideimage and remove the image outputs only for those cells. Does that work?

choldgraf commented 6 years ago

@lwasser did you get this figured out? Can I close this? :-)

lwasser commented 6 years ago

Yes!! Its working great now. Closing. Thanks @choldgraf !!