nteract / papermill

📚 Parameterize, execute, and analyze notebooks
http://papermill.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
5.96k stars 429 forks source link

Error on record() with new versions #80

Closed LPugens closed 6 years ago

LPugens commented 6 years ago

Versions above 0.11 seems to present an error when running the record() function. As the example on the readme file:

"""notebook.ipynb"""
import papermill as pm

pm.record("hello", "world")
pm.record("number", 123)
pm.record("some_list", [1, 3, 5])
pm.record("some_dict", {"a": 1, "b": 2})`

gives:
`---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-447d49aec58c> in <module>()
      2 import papermill as pm
      3 
----> 4 pm.record("hello", "world")
      5 pm.record("number", 123)
      6 pm.record("some_list", [1, 3, 5])

~\Anaconda3\envs\mestrado\lib\site-packages\papermill\api.py in record(name, value)
     33     # IPython.display.display takes a tuple of objects as first parameter
     34     # `http://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.display`
---> 35     ip_display(({RECORD_OUTPUT_TYPE: {name: value}},), raw=True)
     36 
     37 

~\Anaconda3\envs\mestrado\lib\site-packages\IPython\core\display.py in display(include, exclude, metadata, transient, display_id, *objs, **kwargs)
    293     for obj in objs:
    294         if raw:
--> 295             publish_display_data(data=obj, metadata=metadata, **kwargs)
    296         else:
    297             format_dict, md_dict = format(obj, include=include, exclude=exclude)

~\Anaconda3\envs\mestrado\lib\site-packages\IPython\core\display.py in publish_display_data(data, metadata, source, transient, **kwargs)
    118         data=data,
    119         metadata=metadata,
--> 120         **kwargs
    121     )
    122 

~\Anaconda3\envs\mestrado\lib\site-packages\ipykernel\zmqshell.py in publish(self, data, metadata, source, transient, update)
    115         if transient is None:
    116             transient = {}
--> 117         self._validate_data(data, metadata)
    118         content = {}
    119         content['data'] = encode_images(data)

~\Anaconda3\envs\mestrado\lib\site-packages\IPython\core\displaypub.py in _validate_data(self, data, metadata)
     48 
     49         if not isinstance(data, dict):
---> 50             raise TypeError('data must be a dict, got: %r' % data)
     51         if metadata is not None:
     52             if not isinstance(metadata, dict):

TypeError: data must be a dict, got: {'application/papermill.record+json': {'hello': 'world'}}`
rgbkrk commented 6 years ago

Thanks for reporting, I've fixed this in #81.