Skip to content

feat: add app info into object key.#425

Merged
k82cn merged 3 commits into
xflops:mainfrom
k82cn:flm_423
Apr 28, 2026
Merged

feat: add app info into object key.#425
k82cn merged 3 commits into
xflops:mainfrom
k82cn:flm_423

Conversation

@k82cn
Copy link
Copy Markdown
Contributor

@k82cn k82cn commented Apr 28, 2026

No description provided.

Signed-off-by: Klaus Ma <klausm@nvidia.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements RFE423, transitioning the object cache key structure from a two-level format to a three-level format: <app_name>/<session_id>/<object_id>. This change enables application-level object sharing across sessions, supported by a new put_object method in the Runner class and the introduction of reserved session names like 'shared'. The implementation spans the Rust cache server, disk storage logic, and the Python SDK, including a new ObjectKey utility for key parsing and validation. Review feedback highlights the need to update remaining legacy tests to the new format, refine internal error messages in the Rust implementation, and extend key component validation in the Python SDK to explicitly disallow forward slashes.

Comment thread e2e/tests/test_cache.py
def test_cache_put_and_get():
"""Test basic put and get operations."""
session_id = "test-session-001"
key_prefix = "test-app/test-session-001"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While this test has been updated to use the new three-level key format (<app>/<ssn>), several other tests in this file (e.g., test_patch_single_delta, test_patch_multiple_deltas, etc., starting from line 98) still use the old two-level format. Since the API now strictly enforces the new format, those tests will fail. Please ensure all tests in this file are updated to use the app-prefixed key format.

Comment thread object_cache/src/cache.rs Outdated
let key = format!("{}/{}", session_id, object_id);
let key = object_key
.to_key()
.ok_or_else(|| FlameError::Internal("Failed to generate object key".to_string()))?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The error message "Failed to generate object key" is slightly misleading here. In this context, object_key is guaranteed to have an object_id (either provided or generated), so to_key() should not fail. If it does, it's an internal invariant violation rather than a failure to generate the key. Consider using .expect("object_id must be set") or a more descriptive internal error.

Suggested change
.ok_or_else(|| FlameError::Internal("Failed to generate object key".to_string()))?;
.to_key()
.ok_or_else(|| FlameError::Internal("ObjectKey missing object_id in put_with_id".to_string()))?;

Comment thread sdk/python/src/flamepy/core/cache.py Outdated
for name, value in [("app_name", self.app_name), ("session_id", self.session_id)]:
if not value:
raise ValueError(f"{name} cannot be empty")
if ".." in value or "\\" in value:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The validation logic should also check for the forward slash (/) character in key components. Since the slash is used as a separator in the three-level key structure, allowing it within a component (like app_name) would lead to parsing ambiguities and potential errors when the key is reconstructed or validated on the server.

Suggested change
if ".." in value or "\\" in value:
if ".." in value or "\\" in value or "/" in value:

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 83.18584% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
object_cache/src/cache.rs 81.53% 12 Missing ⚠️
object_cache/src/storage/disk.rs 85.41% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

k82cn added 2 commits April 28, 2026 21:04
Signed-off-by: Klaus Ma <klausm@nvidia.com>
Signed-off-by: Klaus Ma <klausm@nvidia.com>
@k82cn k82cn merged commit f52f89f into xflops:main Apr 28, 2026
6 checks passed
@k82cn k82cn deleted the flm_423 branch April 28, 2026 14:54
@k82cn k82cn mentioned this pull request Apr 28, 2026
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 this pull request may close these issues.

1 participant