Skip to content

Add optional TTL configuration for Redis object store#1157

Merged
rapids-bot[bot] merged 2 commits intoNVIDIA:developfrom
thepatrickchin:redis-ttl
Nov 6, 2025
Merged

Add optional TTL configuration for Redis object store#1157
rapids-bot[bot] merged 2 commits intoNVIDIA:developfrom
thepatrickchin:redis-ttl

Conversation

@thepatrickchin
Copy link
Member

@thepatrickchin thepatrickchin commented Nov 6, 2025

Description

This PR adds an optional TTL configuration (in seconds) for Redis object stores. Omitting ttl results in no expiration as before.

object_stores:
  my_object_store:
    _type: redis
    host: localhost
    port: 6379
    db: 0
    bucket_name: my-bucket
    ttl: 3600

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Redis object store supports optional Time To Live (TTL) for objects, enabling automatic expiration after a specified number of seconds.
  • Behavior Change

    • When TTL is configured, newly stored and upserted objects will expire automatically after the TTL; default remains no expiration.
  • Chores

    • TTL values are validated to ensure they are positive when provided.

Signed-off-by: Patrick Chin <8509935+thepatrickchin@users.noreply.github.com>
@thepatrickchin thepatrickchin requested a review from a team as a code owner November 6, 2025 07:25
@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

Adds optional TTL support: RedisObjectStoreClientConfig gains a ttl field with validation enforcing >0 when provided; RedisObjectStore accepts a ttl parameter, stores it as _ttl, and passes it to Redis SET calls (via ex) for put_object and upsert_object when set.

Changes

Cohort / File(s) Summary
Redis Object Store Configuration
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
Added ttl: int | None = Field(default=None, description="TTL in seconds for objects (None = no expiration)") to RedisObjectStoreClientConfig; added @field_validator("ttl") to ensure TTL, if provided, is > 0; updated imports and class docstring.
Redis Object Store Implementation
packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
Added ttl: int | None = None parameter to RedisObjectStore.__init__, stored as _ttl; put_object and upsert_object pass _ttl to Redis SET via ex when not None; updated class docstring and constructor signature.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RedisObjectStore
    participant Redis

    Client->>RedisObjectStore: put_object(key, value) / upsert_object(...)
    Note right of RedisObjectStore: _ttl present? (int | None)

    alt _ttl is set
        RedisObjectStore->>Redis: SET key value EX _ttl NX?/-- (depends on op)
        Redis-->>RedisObjectStore: OK / Error
    else _ttl is None
        RedisObjectStore->>Redis: SET key value NX?/-- (no EX)
        Redis-->>RedisObjectStore: OK / Error
    end

    RedisObjectStore-->>Client: Success / Error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify TTL validator rejects non-positive values and permits None.
  • Confirm _ttl is only passed to Redis SET when not None (avoid passing None to ex).
  • Check constructor/class docstring updates and any import additions (e.g., field_validator).

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add optional TTL configuration for Redis object store' is concise (53 characters), uses imperative mood, and accurately describes the main change in the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (1)

29-34: Consider updating class docstring to mention TTL support.

For consistency with the updated RedisObjectStoreClientConfig docstring, consider mentioning the optional TTL capability in the class documentation.

Example update:

 class RedisObjectStore(ObjectStore):
     """
-    Implementation of ObjectStore that stores objects in Redis.
+    Implementation of ObjectStore that stores objects in Redis with optional TTL.
 
     Each object is stored as a single binary value at key "nat/object_store/{bucket_name}/{object_key}".
+    When TTL is configured, keys will automatically expire after the specified duration in seconds.
     """
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f771887 and 6334617.

📒 Files selected for processing (2)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (1 hunks)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.py: In code comments use the abbreviations: nat (API namespace/CLI), nvidia-nat (package), NAT (env var prefixes); never use these abbreviations in documentation
Follow PEP 20 and PEP 8 for Python style
Run yapf with column_limit=120; yapf is used for formatting (run second)
Indent with 4 spaces (no tabs) and end each file with a single trailing newline
Use ruff (ruff check --fix) as a linter (not formatter) per pyproject.toml; fix warnings unless explicitly ignored
Respect Python naming schemes: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
When re-raising exceptions, use bare raise to preserve stack trace; log with logger.error(), not logger.exception()
When catching and logging without re-raising, use logger.exception() to capture full stack trace
Provide Google-style docstrings for every public module, class, function, and CLI command
Docstring first line must be a concise description ending with a period
Validate and sanitize all user input, especially in web or CLI interfaces
Prefer httpx with SSL verification enabled by default and follow OWASP Top-10 recommendations
Use async/await for I/O-bound work (HTTP, DB, file I/O)
Cache expensive computations with functools.lru_cache or an external cache when appropriate
Leverage NumPy vectorized operations when beneficial and feasible

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
{src/**/*.py,packages/*/src/**/*.py}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{src/**/*.py,packages/*/src/**/*.py}: All importable Python code must live under src/ or packages//src/
All public APIs must have Python 3.11+ type hints on parameters and return values
Prefer typing/collections.abc abstractions (e.g., Sequence over list)
Use typing.Annotated for units or metadata when useful
Treat pyright warnings as errors during development

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
packages/*/src/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

If a package contains Python code, it must have tests in a tests/ directory at the same level as pyproject.toml

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
packages/**/*

⚙️ CodeRabbit configuration file

packages/**/*: - This directory contains optional plugin packages for the toolkit, each should contain a pyproject.toml file. - The pyproject.toml file should declare a dependency on nvidia-nat or another package with a name starting
with nvidia-nat-. This dependency should be declared using ~=<version>, and the version should be a two
digit version (ex: ~=1.0).

  • Not all packages contain Python code, if they do they should also contain their own set of tests, in a
    tests/ directory at the same level as the pyproject.toml file.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
🧠 Learnings (1)
📚 Learning: 2025-08-23T02:55:39.346Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Agent-Toolkit PR: 649
File: src/nat/cli/commands/object_store/object_store.py:32-42
Timestamp: 2025-08-23T02:55:39.346Z
Learning: In the NAT object store plugin architecture, config classes like S3ObjectStoreClientConfig, MySQLObjectStoreClientConfig, and RedisObjectStoreClientConfig are defined in the object_store.py files (e.g., nat.plugins.s3.object_store), while the implementation classes are in separate files (e.g., nat.plugins.s3.s3_object_store). The registration functions are also in the object_store.py files.

Applied to files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
🔇 Additional comments (5)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (1)

26-27: LGTM: Clear docstring update.

The docstring accurately reflects the new optional TTL capability.

packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (4)

36-45: LGTM: Constructor signature properly extended.

The ttl parameter is correctly added to the constructor signature with appropriate type hints and default value.


54-54: LGTM: TTL properly stored as instance attribute.


101-101: LGTM: TTL correctly applied in put_object.

The TTL is properly passed to Redis SET via the ex parameter. When ttl=None, no expiration is set, preserving existing behavior.


113-113: LGTM: TTL correctly applied in upsert_object.

Consistent TTL application in the upsert path.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (1)

27-28: End the summary line with a period.

The docstring summary needs to end with a period to satisfy the Google-style docstring requirement. As per coding guidelines.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6334617 and 10243da.

📒 Files selected for processing (2)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (2 hunks)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.py: In code comments use the abbreviations: nat (API namespace/CLI), nvidia-nat (package), NAT (env var prefixes); never use these abbreviations in documentation
Follow PEP 20 and PEP 8 for Python style
Run yapf with column_limit=120; yapf is used for formatting (run second)
Indent with 4 spaces (no tabs) and end each file with a single trailing newline
Use ruff (ruff check --fix) as a linter (not formatter) per pyproject.toml; fix warnings unless explicitly ignored
Respect Python naming schemes: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
When re-raising exceptions, use bare raise to preserve stack trace; log with logger.error(), not logger.exception()
When catching and logging without re-raising, use logger.exception() to capture full stack trace
Provide Google-style docstrings for every public module, class, function, and CLI command
Docstring first line must be a concise description ending with a period
Validate and sanitize all user input, especially in web or CLI interfaces
Prefer httpx with SSL verification enabled by default and follow OWASP Top-10 recommendations
Use async/await for I/O-bound work (HTTP, DB, file I/O)
Cache expensive computations with functools.lru_cache or an external cache when appropriate
Leverage NumPy vectorized operations when beneficial and feasible

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
{src/**/*.py,packages/*/src/**/*.py}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{src/**/*.py,packages/*/src/**/*.py}: All importable Python code must live under src/ or packages//src/
All public APIs must have Python 3.11+ type hints on parameters and return values
Prefer typing/collections.abc abstractions (e.g., Sequence over list)
Use typing.Annotated for units or metadata when useful
Treat pyright warnings as errors during development

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
packages/*/src/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

If a package contains Python code, it must have tests in a tests/ directory at the same level as pyproject.toml

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
packages/**/*

⚙️ CodeRabbit configuration file

packages/**/*: - This directory contains optional plugin packages for the toolkit, each should contain a pyproject.toml file. - The pyproject.toml file should declare a dependency on nvidia-nat or another package with a name starting
with nvidia-nat-. This dependency should be declared using ~=<version>, and the version should be a two
digit version (ex: ~=1.0).

  • Not all packages contain Python code, if they do they should also contain their own set of tests, in a
    tests/ directory at the same level as the pyproject.toml file.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
🧠 Learnings (1)
📚 Learning: 2025-08-23T02:55:39.346Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Agent-Toolkit PR: 649
File: src/nat/cli/commands/object_store/object_store.py:32-42
Timestamp: 2025-08-23T02:55:39.346Z
Learning: In the NAT object store plugin architecture, config classes like S3ObjectStoreClientConfig, MySQLObjectStoreClientConfig, and RedisObjectStoreClientConfig are defined in the object_store.py files (e.g., nat.plugins.s3.object_store), while the implementation classes are in separate files (e.g., nat.plugins.s3.s3_object_store). The registration functions are also in the object_store.py files.

Applied to files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
🪛 Ruff (0.14.3)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py

41-41: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CI Pipeline / Check

Also mention optional TTL capability in the class documentation.

Signed-off-by: Patrick Chin <8509935+thepatrickchin@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (2)

27-28: Consider enhancing the docstring with TTL behavior details.

The updated docstring accurately mentions TTL support. For improved clarity, consider elaborating on the behavior: "When TTL is provided, stored objects expire after the specified seconds; omitting TTL preserves objects indefinitely."


37-42: Excellent validation logic!

The validator correctly enforces that TTL must be a positive integer when provided, preventing edge cases like 0 (immediate expiration) or negative values. This addresses the past review comment.

Optional style refinement: Ruff flagged TRY003, suggesting error messages could be defined as class constants. However, for configuration validation, inline messages are often clearer. This is purely a style preference.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10243da and 04d0720.

📒 Files selected for processing (2)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (2 hunks)
  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.py: In code comments use the abbreviations: nat (API namespace/CLI), nvidia-nat (package), NAT (env var prefixes); never use these abbreviations in documentation
Follow PEP 20 and PEP 8 for Python style
Run yapf with column_limit=120; yapf is used for formatting (run second)
Indent with 4 spaces (no tabs) and end each file with a single trailing newline
Use ruff (ruff check --fix) as a linter (not formatter) per pyproject.toml; fix warnings unless explicitly ignored
Respect Python naming schemes: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
When re-raising exceptions, use bare raise to preserve stack trace; log with logger.error(), not logger.exception()
When catching and logging without re-raising, use logger.exception() to capture full stack trace
Provide Google-style docstrings for every public module, class, function, and CLI command
Docstring first line must be a concise description ending with a period
Validate and sanitize all user input, especially in web or CLI interfaces
Prefer httpx with SSL verification enabled by default and follow OWASP Top-10 recommendations
Use async/await for I/O-bound work (HTTP, DB, file I/O)
Cache expensive computations with functools.lru_cache or an external cache when appropriate
Leverage NumPy vectorized operations when beneficial and feasible

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
{src/**/*.py,packages/*/src/**/*.py}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{src/**/*.py,packages/*/src/**/*.py}: All importable Python code must live under src/ or packages//src/
All public APIs must have Python 3.11+ type hints on parameters and return values
Prefer typing/collections.abc abstractions (e.g., Sequence over list)
Use typing.Annotated for units or metadata when useful
Treat pyright warnings as errors during development

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
packages/*/src/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

If a package contains Python code, it must have tests in a tests/ directory at the same level as pyproject.toml

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
packages/**/*

⚙️ CodeRabbit configuration file

packages/**/*: - This directory contains optional plugin packages for the toolkit, each should contain a pyproject.toml file. - The pyproject.toml file should declare a dependency on nvidia-nat or another package with a name starting
with nvidia-nat-. This dependency should be declared using ~=<version>, and the version should be a two
digit version (ex: ~=1.0).

  • Not all packages contain Python code, if they do they should also contain their own set of tests, in a
    tests/ directory at the same level as the pyproject.toml file.

Files:

  • packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py
  • packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py
🪛 Ruff (0.14.3)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py

41-41: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (6)
packages/nvidia_nat_redis/src/nat/plugins/redis/object_store.py (2)

17-17: LGTM!

The field_validator import is correctly placed and used appropriately for the TTL validation.


35-35: LGTM!

The TTL field is well-defined with appropriate type hints, default value, and clear description. The None default correctly preserves existing behavior (no expiration).

packages/nvidia_nat_redis/src/nat/plugins/redis/redis_object_store.py (4)

31-35: LGTM!

The docstring accurately describes the TTL functionality. The explanation clearly states that keys expire automatically when TTL is configured, while the existing documentation implies persistence when TTL is not set.


37-55: LGTM!

The constructor signature correctly accepts and stores the TTL parameter with appropriate type hints. The separation of concerns is good—validation happens at the config level, while this class focuses on storage logic.


102-102: LGTM!

The put_object method correctly applies TTL using the ex parameter. When self._ttl is None, Redis will not set an expiration (preserving existing behavior). When self._ttl is a positive integer, the key expires automatically after the specified seconds. The combination of nx=True and ex=self._ttl properly implements conditional creation with optional TTL.


114-114: LGTM!

The upsert_object method correctly applies TTL using the ex parameter. The implementation properly overwrites existing keys (no nx flag) while applying the TTL. Note that upserting resets the expiration timer on existing keys, which is the expected behavior for upsert operations.

@willkill07 willkill07 added improvement Improvement to existing functionality non-breaking Non-breaking change labels Nov 6, 2025
@willkill07
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit 383bc1c into NVIDIA:develop Nov 6, 2025
17 checks passed
@thepatrickchin thepatrickchin deleted the redis-ttl branch November 7, 2025 03:46
saglave pushed a commit to snps-scm13/SNPS-NeMo-Agent-Toolkit that referenced this pull request Dec 11, 2025
This PR adds an optional TTL configuration (in seconds) for Redis object stores. Omitting `ttl` results in no expiration as before.

```
object_stores:
  my_object_store:
    _type: redis
    host: localhost
    port: 6379
    db: 0
    bucket_name: my-bucket
    ttl: 3600
```

## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md).
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
  - Any contribution which contains commits that are not Signed-Off will not be accepted.
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

## Summary by CodeRabbit

* **New Features**
  * Redis object store supports optional Time To Live (TTL) for objects, enabling automatic expiration after a specified number of seconds.

* **Behavior Change**
  * When TTL is configured, newly stored and upserted objects will expire automatically after the TTL; default remains no expiration.

* **Chores**
  * TTL values are validated to ensure they are positive when provided.

Authors:
  - Patrick Chin (https://github.com/thepatrickchin)

Approvers:
  - Will Killian (https://github.com/willkill07)

URL: NVIDIA#1157
Signed-off-by: Sangharsh Aglave <aglave@synopsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants