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

Error in documentation regarding initialisation of RedisBloom and TopK #2415

Closed
radioactive11 opened this issue Oct 12, 2022 · 5 comments · Fixed by #2478
Closed

Error in documentation regarding initialisation of RedisBloom and TopK #2415

radioactive11 opened this issue Oct 12, 2022 · 5 comments · Fixed by #2478

Comments

@radioactive11
Copy link

Link to documentation

Version: redis-py version: 4.3.4 & redis-stack running on Docker (v6.2.7)

Platform: Python 3.10.6 on macOS
Description: Creating a bloom filter or TopK client according to the documentation throws an AttributeError

Sample:

>>> import redis
>>> filter = redis.bf().create("bloom", 0.01, 1000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'redis' has no attribute 'bf'

Solution:

>>> from redis import Redis
>>> r = Redis()
>>> bf = r.bf()
>>> bf.create("bloom", 0.01, 1000)
True

I am facing similar issue with TopK filters as well.

I can raise a PR to solve this issue as well.

@sav-norem
Copy link

sav-norem commented Oct 17, 2022

Hey - thanks for using the library! What a find -

So I get the same error when I do that from the terminal / interpreter, however when I use that syntax in a script it runs just as expected. Could you confirm for me if this syntax works for you in a script?

@radioactive11
Copy link
Author

radioactive11 commented Oct 18, 2022

Hello @sav-norem

I ran the same syntax both in a shell (terminal) and as a script. It throws an error in both cases.

@sav-norem
Copy link

sav-norem commented Oct 18, 2022

@radioactive11 woops! I forgot a key part of my code that works in a script - you sort of got it in the piece that works, but you need to set the r = Redis() (with any other connection parameters you want) and then can do r.bf().create() which means I'll let the docs team know we need to update that sample code - thanks!

@radioactive11
Copy link
Author

@sav-norem Exactly

But in the documentation, the sample that is provided doesn't instantiate a Redis object and directly tries to create an object of type bf which causes the error.

@sav-norem
Copy link

@radioactive11 yup! I've opened an issue with the docs team and we'll leave this open until that change in the docs gets out to the readthedocs page

nermiller added a commit that referenced this issue Nov 30, 2022
* Fixes #2415, adds a connect step to bloom commands

* Update redismodules.rst

Apply feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants