Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.all() not working #34

Closed
dschofield opened this issue Feb 11, 2020 · 10 comments
Closed

.all() not working #34

dschofield opened this issue Feb 11, 2020 · 10 comments
Assignees
Labels

Comments

@dschofield
Copy link

dschofield commented Feb 11, 2020

#31 is still an issue.

I've installed 0.5.1 from tag 0.5.1:
pipenv install git+https://github.com/Miserlou/NoDB.git@0.5.1#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)

@bendog bendog added the bug label Feb 17, 2020
@bendog
Copy link
Collaborator

bendog commented Feb 24, 2020

can you tell me more about your environment?

@bendog bendog self-assigned this Feb 24, 2020
@dschofield
Copy link
Author

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 git+git@github.com: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`

@bendog
Copy link
Collaborator

bendog commented Mar 1, 2020

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

@bendog
Copy link
Collaborator

bendog commented Mar 1, 2020

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?

@dschofield
Copy link
Author

I'll get to test this out this week.

@dschofield
Copy link
Author

dschofield commented Mar 26, 2020

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.

@bendog
Copy link
Collaborator

bendog commented Mar 27, 2020

can you paste the whole process?

@bendog
Copy link
Collaborator

bendog commented Mar 27, 2020

@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 ?

@dschofield
Copy link
Author

dschofield commented Apr 6, 2020

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}]
`

@bendog
Copy link
Collaborator

bendog commented Apr 18, 2020

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

@bendog bendog closed this as completed May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants