activeloopai / deeplake

Database for AI. Store Vectors, Images, Texts, Videos, etc. Use with LLMs/LangChain. Store, query, version, & visualize any AI data. Stream data in real-time to PyTorch/TensorFlow. https://activeloop.ai
https://activeloop.ai
Mozilla Public License 2.0
8.05k stars 614 forks source link

[FEATURE] Redis storage provider #1168

Open kristinagrig06 opened 3 years ago

kristinagrig06 commented 3 years ago

🚨🚨 Feature Request

If your feature will improve HUB

Support Redis as a storage provider for Hub datasets.

Description of the possible solution

Implementations of already supported storage providers can be used as examples: S3 storage, local storage, etc.

Difficulty: Medium

krishnajalan commented 2 years ago

So a Redis client need to be implemented?

up4154 commented 2 years ago

can you assign me this please

dhiganthrao commented 2 years ago

@krishnajalan, apologies for the delay! Yep, similar to how we can store Hub datasets on platforms like S3, we need to implement a way to store Hub datasets as a Redis database.

dhiganthrao commented 2 years ago

@up4154 welcome to Hub, and Hacktoberfest! Great to see that you're willing to contribute. Do you have a proposed solution in mind?

mikayelh commented 2 years ago

This one is still up for grabs! :)

aadityasinha-dotcom commented 2 years ago

Can I work on this issue?

tatevikh commented 2 years ago

Hi @aadityasinha-dotcom! Thanks for your interest in Hub. I just assigned it to you. Have fun!

aadityasinha-dotcom commented 2 years ago

Thanks 👍

aadityasinha-dotcom commented 2 years ago

So we have to implement Redis client just like we implemented the S3 storage.

mikayelh commented 2 years ago

correct, @aadityasinha-dotcom ! :)

olivia632 commented 2 years ago

hey can i work on this

aadityasinha-dotcom commented 2 years ago

A small question. Is this the correct implementation for redis client? @farizrahman4u

class ReadisProvider(redis_url):
    """Provider class for using the local filesystem."""

    def __init__(self, redis_url):
        """Initializes the RedisProvider.
        Args:
            redis_url: The url of the provider.    
        """

        self.r = redis.StrictRedis(url = redis_url, charset = "utf-8", decode_responses = True)

Function to set the value for given bitfield

def set(self, fmt: str, offset: BitfieldOffsetT, value: int):
        """
        Set the value of a given bitfield.
        :param fmt: format-string for the bitfield being read, e.g. 'u8' for
            an unsigned 8-bit integer.
        :param offset: offset (in number of bits). If prefixed with a
            '#', this is an offset multiplier, e.g. given the arguments
            fmt='u8', offset='#2', the offset will be 16.
        :param int value: value to set at the given position.
        :returns: a :py:class:`BitFieldOperation` instance.
        """
        self.operations.append(("SET", fmt, offset, value))
        return self
farizrahman4u commented 2 years ago

@aadityasinha-dotcom this isnt even valid python: class ReadisProvider(redis_url):, how are you inheriting from a string?

And no, this isnt an implementation of redis provider for hub. You just copied a random snippet from walrus which uses variables (like self.operations) that are defined no where in your code. You are doing the same thing as you did in #1588. This is not acceptable.

aadityasinha-dotcom commented 2 years ago

Sorry for doing the same thing. I promise I will not do that again. I have referenced this from https://redis.readthedocs.io/en/latest/commands.html#core-commands

aadityasinha-dotcom commented 2 years ago

From what I found redis is like a dictionary which holds key:value pairs. And I have to implement redis client with its commands like get, set, del, etc.

aadityasinha-dotcom commented 2 years ago

@farizrahman4u Is it necessary to pass all the parameters?


def __init__(self, host='localhost', port=6379,
                 db=0, password=None, socket_timeout=None,
                 socket_connect_timeout=None,
                 socket_keepalive=None, socket_keepalive_options=None,
                 connection_pool=None, unix_socket_path=None,
                 encoding='utf-8', encoding_errors='strict',
                 charset=None, errors=None,
                 decode_responses=False, retry_on_timeout=False,
                 ssl=False, ssl_keyfile=None, ssl_certfile=None,
                 ssl_cert_reqs='required', ssl_ca_certs=None,
                 max_connections=None):
aadityasinha-dotcom commented 2 years ago

I have implemented it like this is this ok?

Screenshot from 2022-04-12 17-28-08