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

Scrap of type Int not supported #71

Closed davidbrochart closed 4 years ago

davidbrochart commented 4 years ago

It seems that this doesn't work:

import scrapbook as sb
sb.glue('number', 123)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-3-876a51da60d5> in <module>
----> 1 sb.glue('number', 123)

~/minimamba3/envs/subnotebook-dev/lib/python3.8/site-packages/scrapbook/utils.py in wrapper(*args, **kwds)
     63         if not is_kernel():
     64             warnings.warn("No kernel detected for '{fname}'.".format(fname=f.__name__))
---> 65         return f(*args, **kwds)
     66 
     67     return wrapper

~/minimamba3/envs/subnotebook-dev/lib/python3.8/site-packages/scrapbook/api.py in glue(name, data, encoder, display, return_output)
     74     if not encoder:
     75         try:
---> 76             encoder = encoder_registry.determine_encoder_name(data)
     77         except NotImplementedError:
     78             if display is not None:

~/minimamba3/envs/subnotebook-dev/lib/python3.8/site-packages/scrapbook/encoders.py in determine_encoder_name(self, data)
     90             if encoder.encodable(data):
     91                 return name
---> 92         raise NotImplementedError(
     93             "Scrap of type {stype} has no supported encoder registered".format(stype=type(data))
     94         )

NotImplementedError: Scrap of type <class 'int'> has no supported encoder registered
MSeal commented 4 years ago

Yeah that's a bug imo.

import scrapbook as sb
sb.glue('number', 123, 'json')

will work atm. I had fixed these type of default type encoder issues in https://github.com/nteract/scrapbook/pull/37 (this WIP needed interface concerns resolved and I extracted the pandas encoder) but I didn't come back and finish the remote storage work which improved encoder patterns.

MSeal commented 4 years ago

0.4.1 has this fixed btw, it was a bug introduced in a refactor