feat(rag): add StorageBase interface for encrypted storage#13458
feat(rag): add StorageBase interface for encrypted storage#13458Achieve3318 wants to merge 3 commits intoinfiniflow:mainfrom
Conversation
|
Hi, @yingfeng , Please review my PR. Thanks |
|
Hi, @KevinHuSh , Could you review my PR if you have time? Thanks |
|
What's the design purpose of this PR? |
Hi, @yingfeng , Thank you for your review. I updated description of this PR. Please check again. |
|
I meant why introducing a base class for EncryptedStorage? It's just a utility to wrap up other S3 storage. There does not exist a so-called in-memory storage, and then adding new storage type as |
|
@yingfeng , Thanks for the feedback. I’ve removed the The |
|
Hi, @yingfeng , Could you review my PR again? Thank you |
|
So, what's left in this PR? |
At this point the PR is very small
|
|
I replaced TODO with note that backends should implement StorageBase, with defensive runtime checks for duck typing. |
|
I can only see some comments |
oh, sorry, I had mistake. Please review again. Thank you for your review |
|
@yingfeng , If you have time, please check my updates again. Thank you |
|
@yingfeng . Please check my PR if you have time |
Design Purpose
Define a formal storage abstraction
Introduce
StorageBaseinrag/utils/storage_base.pyas the canonical interface for storage backends used with encrypted storage. It declares the required operations (put,get,rm,obj_exist,health) instead of relying on ad-hochasattrchecks.Make
EncryptedStorageWrappersafer and self-documentingEncryptedStorageWrappernow expects aStorageBaseimplementation (with a defensive runtime check). This clarifies what backends must provide, reduces the risk of partially implemented or incompatible backends, and makes it easier for new backends (MinIO, S3, filesystem, etc.) to integrate by implementing one interface.Enable local, dependency-free tests for storage behavior
Add an in-memory
InMemoryStorageimplementation and unit tests intest_storage_base.pyso the storage contract can be validated without external services or configuration.File Changes
Modified files
rag/utils/encrypted_storage.py(+3, -3)from rag.utils.storage_base import StorageBase.EncryptedStorageWrapper.__init__: parameter type hintstorage_impl: StorageBase.StorageBase, with defensive runtime checks for duck typing.Type of change