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

Not being able to access parameters when load the whole directory #47

Closed tqa236 closed 6 months ago

tqa236 commented 5 years ago

Hello, I just use papermill and scrapbook recently and they are fantastic. I have a small issue now and I'm sorry if it's a little naive.

When I load a single notebook with scrapbook, I can access the parameters I use for papermill

import scrapbook as sb
nbs = sb.read_notebook(path/to/notebook)
nbs.parameters

However, when I load all the notebooks from a directory, I can not find where is the parameters for each notebook. book = sb.read_notebooks('result/')

book = sb.read_notebooks(directory/to/notebooks)

Can I know how to access the parameters of each notebook in the latter case?

MSeal commented 5 years ago

Looks like we don't have that method defined on the Scrapbook collection. You could emulate the scraps behavior with merge_dicts(nb.parameters for nb in sb.notebooks) or OrderedDict([(key, nb.parameters ) for key, nb in sb._notebooks.items()]).

Would be an easy feature to add if you wanted to :)

tqa236 commented 5 years ago

Thank you very much. I'm able to do that now. This code can access the scraps and the parameters at the same time:

for scraps, nb in zip(book.notebook_scraps, book.notebooks):
    print(scraps)
    print(nb.parameters)