deeplake icon indicating copy to clipboard operation
deeplake copied to clipboard

[FEATURE] Redis storage provider

Open kristinagrig06 opened this issue 3 years ago • 17 comments

🚨🚨 Feature Request

  • [ ] Related to an existing Issue
  • [x] A new implementation (Improvement, Extension)

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

kristinagrig06 avatar Sep 12 '21 18:09 kristinagrig06

So a Redis client need to be implemented?

krishnajalan avatar Oct 07 '21 14:10 krishnajalan

can you assign me this please

up4154 avatar Oct 20 '21 14:10 up4154

@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 avatar Oct 21 '21 02:10 dhiganthrao

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

dhiganthrao avatar Oct 21 '21 02:10 dhiganthrao

This one is still up for grabs! :)

mikayelh avatar Jan 13 '22 19:01 mikayelh

Can I work on this issue?

aadityasinha-dotcom avatar Mar 10 '22 08:03 aadityasinha-dotcom

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

tatevikh avatar Mar 10 '22 15:03 tatevikh

Thanks 👍

aadityasinha-dotcom avatar Mar 10 '22 15:03 aadityasinha-dotcom

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

aadityasinha-dotcom avatar Mar 10 '22 17:03 aadityasinha-dotcom

correct, @aadityasinha-dotcom ! :)

mikayelh avatar Mar 10 '22 17:03 mikayelh

hey can i work on this

olivia632 avatar Mar 28 '22 18:03 olivia632

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

aadityasinha-dotcom avatar Apr 12 '22 07:04 aadityasinha-dotcom

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

farizrahman4u avatar Apr 12 '22 07:04 farizrahman4u

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 avatar Apr 12 '22 07:04 aadityasinha-dotcom

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 avatar Apr 12 '22 08:04 aadityasinha-dotcom

@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 avatar Apr 12 '22 10:04 aadityasinha-dotcom

I have implemented it like this is this ok?

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

aadityasinha-dotcom avatar Apr 12 '22 13:04 aadityasinha-dotcom