Open nicole-brewer opened 1 year ago
Okay, instead of making this an issue for every notebook, I'm going to just do something more centralized here. I need to make a script that does a lot of this for me. One goal is to pull in answers to a cell when the user gets stuck. I can see two ways to do this...
The part I haven't figured out here is how to deal with editing notebooks.
Okay so I'm going with option two. I wrote an ipython magic that pulls in code chunks from the exported python file with filepath and cell number parameters. I decided to have the answers (for any part of the tutorial, doesn't have to just be dashboard) go in a key
directory. I was going to have it be a hidden folder, but that's not agreeable with the way python imports work. I was thinking about putting the key folder inside the dashboard folder, but that's a bad idea because I don't want bad things to happen if we delete the dashboard folder altogether for some reason
So perhaps I've established somewhere that the ipython magic that pulls chunks from the exported python file can only do so on exported cells, which is an oversight on my part. What about cells that aren't exported? I was thinking I'd have to scrap the old magic and write a new one that writes all the answers to files, but actually, the old way of doing it is still needed. If a user has trouble with an old notebook, they can import the module from the key directory. So it's not like I wasted work there. But I also need a solution for pulling in answers from cells that weren't exported. So I need to write another magic function that exports answers to a different directory in key
. I can write this function so that it leaves in the comments to the right hand side. But when to do this. Could make it an option to leave in the answer until a flag is used. Only then does the code get stripped away leaving the comments. A commented out command with %load or %answer needs to be added before the first line. Probably %answer to keep it consistent. This means I need to add an option to answer that doesn't take a cell number, just a file. The command for exporting the answer could be %%export --hold could prevent the answer being replaced with the comments. This will be a little ugly, because the imported answer needs to have the commented out code on it still in case the code gets exported but then needs to be imported to get changed again. But that's a small thing.
key/path/to/file.py
For each notebook:
dashboard
andkey/dashboard
Before the tutorial:
nb_export('03_dashboarding.ipynb', '.dashboard_key')
)