NoDB icon indicating copy to clipboard operation
NoDB copied to clipboard

.all() not working

Open dschofield opened this issue 5 years ago • 10 comments

#31 is still an issue.

I've installed 0.5.1 from tag 0.5.1: pipenv install git+https://github.com/Miserlou/[email protected]#egg=nodb and tried locally from the 0.5.1 tarball also

(btw, the version in setup.py still shows 0.4.0)

nodb.all() returns the error

Traceback (most recent call last): File "", line 1, in File "/home/dschofield/clients/mdg/NoDB-0.5.1/nodb/init.py", line 202, in all deserialized_objects.append(self._deserialize(serialized)) File "/home/dschofield/clients/mdg/NoDB-0.5.1/nodb/init.py", line 252, in _deserialize deserialized = json.loads(serialized) File "/usr/local/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.6/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)

dschofield avatar Feb 11 '20 22:02 dschofield

can you tell me more about your environment?

bendog avatar Feb 24 '20 09:02 bendog

Sure: Debian GNU/Linux 9.11 (stretch) Linux penguin 4.19.79-07511-ge32b3719f26b #1 SMP PREEMPT Mon Nov 18 17:41:41 PST 2019 x86_64 GNU/Linux Python 3.6.9 and pipenv for virrual environment

pip freeze

appdirs==1.4.3 attrs==19.3.0 aurora-data-api==0.2.0 backcall==0.1.0 bleach==3.1.1 boto3==1.12.8 botocore==1.15.8 coverage==4.3.4 decorator==4.4.1 defusedxml==0.6.0 docutils==0.15.2 entrypoints==0.3 et-xmlfile==1.0.1 funcsigs==1.0.2 future==0.18.2 futures==3.0.5 -e [email protected]:dschofield/goldmine.git@8ba011b3ad4fdf0e77303773547e2a24b410e5a7#egg=goldmine importlib-metadata==1.5.0 ipykernel==5.1.4 ipython==7.12.0 ipython-genutils==0.2.0 ipywidgets==7.5.1 jdcal==1.4.1 jedi==0.16.0 Jinja2==2.11.1 jmespath==0.9.5 jsonschema==3.2.0 jupyter==1.0.0 jupyter-client==6.0.0 jupyter-console==6.1.0 jupyter-core==4.6.3 MarkupSafe==1.1.1 mistune==0.8.4 nbconvert==5.6.1 nbformat==5.0.4 nodb==0.4.0 ## !! installed from 0.5.1 tag !! nose==1.3.7 notebook==6.0.3 numpy==1.18.1 openpyxl==3.0.3 packaging==20.1 pandas==1.0.1 pandocfilters==1.4.2 parso==0.6.2 pbr==5.4.4 pexpect==4.8.0 pickleshare==0.7.5 prometheus-client==0.7.1 prompt-toolkit==3.0.3 ptyprocess==0.6.0 PyAthena==1.10.1 Pygments==2.5.2 pyparsing==2.4.6 pyrsistent==0.15.7 python-dateutil==2.8.1 pytz==2019.3 pyzmq==19.0.0 qtconsole==4.6.0 s3transfer==0.3.3 Send2Trash==1.5.0 six==1.14.0 tenacity==6.1.0 terminado==0.8.3 testpath==0.4.4 tornado==6.0.3 traitlets==4.3.3 urllib3==1.25.8 wcwidth==0.1.8 webencodings==0.5.1 widgetsnbextension==3.5.1 xlrd==1.2.0 zipp==3.0.0`

dschofield avatar Feb 28 '20 15:02 dschofield

seems to be issues with python3.6 specifically, i'm working through getting the tests functional again.

bendog avatar Mar 01 '20 03:03 bendog

so i've got the tests working again, however i'm not sure if it will solve the issue. is this an issue when there is no data to return?

bendog avatar Mar 01 '20 03:03 bendog

I'll get to test this out this week.

dschofield avatar Mar 16 '20 15:03 dschofield

Sorry this took me so long...no dice.

Following the documented example.

acache.save({"name": "Kat", "age": 19})
True
acache.load('Kat')
{'name': 'Kat', 'age': 19}
acache.all()
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-24-76b88c7ca4c0> in <module>
----> 1 acache.all()
~/.local/share/virtualenvs/goldmine-hCKJOvFR/lib/python3.6/site-packages/nodb/__init__.py in all(self, metainfo)
    200             serialized = obj.get()["Body"].read()
    201             # deserialize and add to list
--> 202             deserialized_objects.append(self._deserialize(serialized))
    203 
    204         # sort by insert datetime
~/.local/share/virtualenvs/goldmine-hCKJOvFR/lib/python3.6/site-packages/nodb/__init__.py in _deserialize(self, serialized)
    249         obj = None
    250         if type(serialized) == bytes:
--> 251             serialized = serialized.decode()
    252         deserialized = json.loads(serialized)
    253         return_me = {}
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

The same object (successfully) deserialized by .load() doesn't try to decode bytes.

dschofield avatar Mar 26 '20 21:03 dschofield

can you paste the whole process?

bendog avatar Mar 27 '20 07:03 bendog

@dschofield, it might be that you created this bucket with an older version of nodb, and so there might be legacy items in the bucket, are you able to check the bucket is empty before you start testing ?

bendog avatar Mar 27 '20 07:03 bendog

Magically, it's working just fine now. Thanks!

`from nodb import NoDB nodb = NoDB('goldmine-assets', profile_name='mdg') nodb.index='name'

a_user={'name': 'David', 'age': 53} b_user={'name':'Kat', 'age':47}

nodb.save(a_user) True

nodb.load('David') {'name': 'David', 'age': 53}

nodb.save(b_user) True

nodb.load('Kat') {'name': 'Kat', 'age': 47} nodb.all()

[{'name': 'David', 'age': 53}, {'name': 'Kat', 'age': 47}] `

dschofield avatar Apr 06 '20 02:04 dschofield

should probably write a test to determine if that will be an issue

bendog avatar Apr 18 '20 08:04 bendog