nteract / scrapbook

A library for recording and reading data in notebooks.
https://nteract-scrapbook.readthedocs.io
BSD 3-Clause "New" or "Revised" License
281 stars 26 forks source link

Reverse operation for `glue` #82

Open mirekphd opened 3 years ago

mirekphd commented 3 years ago

I started building[1] on an example from the docs here, but wasn't able to find a method to remove these sample Scraps added with glue:

sb.glue("hello", "world")
sb.glue("number", 123)
sb.glue("some_list", [1, 3, 5])
sb.glue("some_dict", {"a": 1, "b": 2})
sb.glue("non_json", df, 'pandas')

Does a reverse operation to glue exist? If not, will it be possible to add it to enable ungluing of unwanted Scraps from notebooks?


[1] a modeling "metapipeline" composed of several serially dependent "classic" modeling pipelines, all executed (using papermill) on the basis of the same template notebook (factory) and producing a model whose MLflow run ID (generated inside the output notebook) will be passed to the next modeling stage using a Scrap glued to the output notebook (which requires much less boilerplate than Luigi by the way, many thanks!)

mirekphd commented 3 years ago

I've just noticed that simply not calling glue for unwanted Scraps (e.g. by executing notebook cell with all unwanted glue calls commented out) and then saving the notebook will avoid glueing these unwanted Scraps (effectively deleting them / unglueing). Brilliant, and again consistent with the KISS principle!

MSeal commented 3 years ago

@mirekphd You got the mechanism as it was intended. That being said adding an unglue function could be useful if one is inheriting some function implementation that adds scraps you don't want in the final size. I'll keep it as an enhancement request issue for future work.