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

scrapbook does not handle string records from pm<1.0 #43

Closed vizhur closed 5 years ago

vizhur commented 5 years ago

I have notebooks that use papermill.record API. For the smooth transition I want to switch to sb.read_notebook that suppose? to handle records from both pm.record and sb.glue. I've got the error when there is a string record

nb = sb.read_notebook('testpm09.ipynb') nb.scraps Traceback (most recent call last): File "", line 1, in File "[CONDAENVS]:\env\lib\site-packages\scrapbook\models.py", line 175, in scraps self._scraps = self._fetch_scraps() File "[CONDAENVS]:\env\lib\site-packages\scrapbook\models.py", line 145, in _fetch_scraps output_data_scraps = self._extract_output_data_scraps(output) File "[CONDAENVS]:\env\lib\site-packages\scrapbook\models.py", line 115, in _extract_output_data_scraps scrap = self._extract_papermill_output_data(sig, payload) File "[CONDAENVS]:\env\lib\site-packages\scrapbook\models.py", line 109, in _extract_papermill_output_data return encoder_registry.decode(Scrap(name, data, encoder)) File "[CONDAENVS]:\env\lib\site-packages\scrapbook\encoders.py", line 91, in decode return loader.decode(scrap, **kwargs) File "[CONDAENVS]:\env\lib\site-packages\scrapbook\encoders.py", line 125, in decode scrap = scrap._replace(data=json.loads(scrap.data)) File "[CONDAENVS]:\env\lib\json__init__.py", line 319, in loads return _default_decoder.decode(s) File "[CONDAENVS]:\env\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "[CONDAENVS]:\env\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

pm.record("string","foo")

MSeal commented 5 years ago

Can you attach the notebook with which you had this error? You might need to change the extension to .txt for GitHub to host it.

I'll look into reproducing idependently today.

vizhur commented 5 years ago

@MSeal thanks for a quick response, it's just one cell: import papermill as pm pm.record("string","this is a string")

here is the nb: test-pm==0.18.2.ipynb.txt