Skip to content

Instantly share code, notes, and snippets.



Last active Jul 9, 2020
What would you like to do?
Suggestion for PowerShell Extension for VS Code / Azure Data Studio

Everyone knows that one of the ‘selling points’ of Jupyter Notebooks is that you can store the results in the Notebook after you have run the code. This is ideal when you have a chance to save the Notebook, or have already completed development of what the code in the Notebook should be. However, when you are still in the middle of developing the code that will ultimately get saved in your Notebook, you may through many iterations of code, before you arrive at your final product. During that process you might want to try things a different way. However, you might end up finding out the other way doesn't work and through that effort you may have broken your code. Now you want to go back several iterations to a good working version.

Idea: What if we could tie Get-History back to a specific cell in the Notebook?

Scenario: Let’s say that a Notebook has 7 code cells, and you’re editing cell #7. You switch from using | foreach {} to use foreach ($Thing in $Things) {…} instead, or maybe even vice versa. You think you’re done making the necessary changes, but the new code doesn’t work. You want to go back and get a copy of the last time(s) the code in just cell #7 executed successfully, so you can make sure you converted everything. Once you have this working version of the old code, you may even want to create it as a new code cell (#8) so that you don’t overwrite the progress you have already made. This is a simplified example, but the key here would be to be able to filter out all the execution history of the other code cells, because you don’t want to get distracted by them. You only care about code blocks that were successfully executed in cell #7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.