drivendataorg/nbautoexport

Proposal: delete auto-exported file that are renamed

cccntu opened this issue · 3 comments

Currently if I rename a notebook, the exported file with old name is not deleted.

jayqi commented

Hi @cccntu, thank you for using nbautoexport and for opening the issue.

Have you taken a look at the experimental clean command? You can check out the documentation page for it to see more about how to use it. We developed the clean command for this exact use case. The clean command works by checking files that exist against files that are expected to exist based on present notebooks. However, this is something you'll have to do manually, and it won't work automatically.

As for developing some kind of automatic functionality:

  • I don't know of a way to know when a notebook as been renamed. If you're renaming the notebook through Jupyter and Jupyter has some kind of event and hook for it, we can potentially do something with that, but I don't know about any functionality like that in Jupyter. However, this still won't work if you're renaming the notebook using a shell or if you rename it through your OS file browser. A completely general solution will probably be impossible for us to handle.
  • We did consider having the aforementioned clean command be able to run automatically after exporting, but we decided that having files deleted without user input needs a really high bar of reliability, and that clean's heuristic isn't good enough.

Let us know what you think!

Hi @jayqi , thank you for the thorough explanation.

  • I just checked out the doc and tried the clean command, and I think it's good. Also, I think the design consideration is very reasonable.
  • I also tried the export command, but found they always exports every files. Maybe we can check the modified time and only export the necessary files? (like in Make) So user can add this command in Makefile without generating all the files each time. And add a flag to force regenerating everything.
jayqi commented

Awesome. I am going to close this issue for now since it looks like the clean command is good enough. We can later if there is a lot of demand for an automatic solution.

I've opened #67 for your suggestion about export.