I use a Papermill notebook ("orchester_notebook") to launch multiple times a "training_notebook" with different sets of parameters.

For each set of parameters, a new "result_notebook" is saved with printed results (text) and figures.

I know how to display the figure from the "result_notebook" in my "orchester notebook"

but I wish to also display the text results (accuracy, classification report,....) in my "orchester_notebook".

Do you know if it is possible to reglue text via scrapbook ?

my code below :


import papermill as pm
import scrapbook as sb

experiment_dates = [20190101, 20190102]
features = 'my_features'
model = 'my_model'
parameters = dict({'experiment_dates' : experiment_dates, 'features' : 
features, 'model' : model})

output_filename = str(experiment_dates) + '_' + features + model

pm.execute_notebook('Training.ipynb', output_filename + '.ipynb', 

out = sb.read_notebook(output_filename + '.ipynb')


import scrapbook as sb

# training

fig, ax = plt.subplots()
ax.plot(data.index, data['mydata'], c='k', alpha=.5)
sb.glue('figure', fig, 'display')

print("this is my results") # how can I reglue this in orchestrer_notebook ?

2 Answers

Brigitte Charpent On

I missed this in the doc :

"""glue example for recording data values"""
import scrapbook as sb

sb.glue("hello", "world") # this answers my need to reglue text
sb.glue("number", 123)
sb.glue("some_list", [1, 3, 5])
sb.glue("some_dict", {"a": 1, "b": 2})
sb.glue("non_json", df, 'arrow')
Brigitte Charpent On

The answer above doesn't work for me, I read this other doc part and the below solution works for me :

in the training notebook :

  display=('text/plain',) # This passes [text/plain] to format_display_data's include argument

in the orchetrer notebook :