Skip to content

feat(blocks): Adding Redis Integration #9723

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

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

Abhi1992002
Copy link
Contributor

@Abhi1992002 Abhi1992002 commented Mar 29, 2025

What I Did

These blocks use the redis-py library to connect and run commands.

Block Details

Here is a list of the new blocks and what they do:

Block Name ✨ What It Does 🧐 Key Features / Options ✅
RedisGetBlock Gets the value for a specific key. Returns the value or nothing if the key doesn't exist.
RedisSetBlock Saves or updates a value for a key. Set time limit (expires), Set only if new (NX) or only if exists (XX).
RedisDeleteBlock Removes one or more keys. Tells how many keys were removed.
RedisExistsBlock Checks if keys are in Redis. Tells how many of the checked keys exist.
RedisAtomicCounterBlock Changes a number stored in a key (adds/subtracts). Choose amount to add/subtract. Set starting number if key is new.
RedisInfoBlock Gets information about the Redis server. Can ask for specific info (like 'memory', 'clients').
RedisListPushBlock Adds items to the start or end of a list. Choose start (LEFT) or end (RIGHT). Tells the new list size.
RedisListPopBlock Removes and gets an item from the start or end of a list. Choose start (LEFT) or end (RIGHT). Can wait if the list is empty.
RedisListGetBlock Gets a part of a list (using start/end positions). Get all items or just some from the list.
RedisPublishBlock Sends (publishes) a message to a channel. Tells how many listeners (clients) got the message.

d Redis blocks for database operations
Copy link

netlify bot commented Mar 29, 2025

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit 2b15d72
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/67eeb7ac7ee65400087b9bd7

Copy link

netlify bot commented Mar 29, 2025

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 2b15d72
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/67eeb7acd444cd00083527e1

@Abhi1992002 Abhi1992002 changed the title WIP : Add Redis integration WIP : Adding Redis integration Mar 29, 2025
Copy link

deepsource-io bot commented Mar 29, 2025

Here's the code health analysis summary for commits 4a82edb..2b15d72. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 17 occurences introduced
🎯 14 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ Success
❗ 11 occurences introduced
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@Abhi1992002
Copy link
Contributor Author

My tests were breaking because of Poetry, so I updated Poetry to 2.1.2 and regenerated the lock file.

@Abhi1992002 Abhi1992002 marked this pull request as ready for review March 30, 2025 04:33
@Abhi1992002 Abhi1992002 requested a review from a team as a code owner March 30, 2025 04:33
@Abhi1992002 Abhi1992002 requested review from Swiftyos and aarushik93 and removed request for a team March 30, 2025 04:33
Copy link

Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

9722 - Partially compliant

Compliant requirements:

  • RedisGetBlock: Retrieves the value stored at a specific key
  • RedisSetBlock: Stores or updates a value for a key, optionally setting an expiry time or conditions
  • RedisDeleteBlock: Removes one or more specified keys and their associated values
  • RedisExistsBlock: Checks if one or more specified keys exist in the database
  • RedisAtomicCounterBlock: Atomically increases or decreases the integer value stored at a key
  • RedisInfoBlock: Retrieves information and statistics about the Redis server instance
  • RedisListPushBlock: Adds one or more elements to the beginning or end of a list
  • RedisListPopBlock: Removes and returns an element from the beginning or end of a list, optionally waiting if empty
  • RedisPublishBlock: Sends (publishes) a message to a specific communication channel

Non-compliant requirements:

  • RedisSubscribeBlock: Listens for messages published to specified communication channels (noted as "might cover in different PR for Redis Trigger")
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling

The error handling pattern returns default values (like empty lists, 0, etc.) when errors occur, which might mask actual errors. Consider if this is the intended behavior or if errors should propagate to callers.

except Exception as e:
    yield "success", False
    yield "error", str(e)
Connection Reuse

Each block creates a new Redis connection for every operation. Consider implementing connection pooling or reusing connections for better performance in high-volume scenarios.

with redis.Redis(
    host=input_data.host,
    port=input_data.port,
    username=(
        credentials.username.get_secret_value()
        if credentials.username
        else "default"
    ),
    password=(
        credentials.password.get_secret_value()
        if credentials.password
        else None
    ),
    decode_responses=True,  # Decode from bytes to str automatically
) as r:
Potential Bug

In RedisListPopBlock, when using blocking operations (blpop/brpop), the result handling might not correctly handle timeout cases where result is None.

value = (
    result[1]
    if result and isinstance(result, (list, tuple))
    else None
)

@Abhi1992002 Abhi1992002 changed the title WIP : Adding Redis integration feat(blocks): Adding Redis Integration Mar 30, 2025
@a-holm
Copy link

a-holm commented Apr 1, 2025

Thanks for adding the Redis integration! The implementation of the new Redis blocks in autogpt_platform/backend/backend/blocks/redis/redis.py looks well-structured and aligns nicely with the described functionality. The corresponding changes in providers.py and the frontend files also look good.

However, the changes to poetry.lock include updates to over 80 unrelated dependencies besides adding redis. This significantly expands the scope of this PR beyond the stated intent of adding Redis integration and introduces a high risk of unintended consequences or breaking changes elsewhere in the application.

Could you please revert the unrelated dependency updates in poetry.lock? It would be best to handle dependency updates in a separate PR where their impact can be assessed and tested independently. Once the lock file only reflects the changes needed for the redis package, this PR should be in good shape for merging in my opinion.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 1, 2025
Copy link
Contributor

github-actions bot commented Apr 1, 2025

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🆕 Needs initial review
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants