@@ -219,8 +219,8 @@ def supports_clear(self, custom_meta: str) -> bool:
219219
220220 def clear (self , keys : list [str ]):
221221 for i in range (0 , len (keys ), self .GET_CLEAR_KEYS_LIMIT ):
222- batch = keys [i : i + self .GET_CLEAR_KEYS_LIMIT ]
223- self ._ds_client .delete (batch )
222+ batch_keys = keys [i : i + self .GET_CLEAR_KEYS_LIMIT ]
223+ self ._ds_client .delete (batch_keys )
224224
225225 @staticmethod
226226 def calc_packed_size (items : list [memoryview ]) -> int :
@@ -342,7 +342,7 @@ def __init__(self, config: dict[str, Any]):
342342 if not self ._strategies :
343343 raise RuntimeError ("No storage strategy available for YuanrongStorageClient" )
344344
345- def put (self , keys : list [str ], values : list [Any ]) -> Optional [ list [Any ] ]:
345+ def put (self , keys : list [str ], values : list [Any ]) -> list [str ]:
346346 """Stores multiple key-value pairs to remote storage.
347347
348348 Automatically routes NPU tensors to high-performance tensor storage,
@@ -353,15 +353,17 @@ def put(self, keys: list[str], values: list[Any]) -> Optional[list[Any]]:
353353 values (List[Any]): List of values to store (tensors, scalars, dicts, etc.).
354354
355355 Returns:
356- List[Any ]: custom metadata of YuanrongStorageCilent in the same order as input keys.
356+ List[str ]: custom metadata of YuanrongStorageCilent in the same order as input keys.
357357 """
358358 if not isinstance (keys , list ) or not isinstance (values , list ):
359359 raise ValueError ("keys and values must be lists" )
360360 if len (keys ) != len (values ):
361361 raise ValueError ("Number of keys must match number of values" )
362362
363363 routed_indexes = self ._route_to_strategies (values , lambda strategy_ , item_ : strategy_ .supports_put (item_ ))
364- custom_metas = [None ] * len (keys )
364+ custom_metas : list [str ] = ["" ] * len (keys )
365+
366+ # Todo(dpj): Parallel put
365367 for strategy , indexes in routed_indexes .items ():
366368 if not indexes :
367369 continue
@@ -382,7 +384,7 @@ def get(self, keys: list[str], shapes=None, dtypes=None, custom_meta=None) -> li
382384 keys (List[str]): Keys to fetch.
383385 shapes (List[List[int]]): Expected tensor shapes (use [] for scalars).
384386 dtypes (List[Optional[torch.dtype]]): Expected dtypes; use None for non-tensor data.
385- custom_meta (List[str], optional ): Device type (npu/cpu) for each key
387+ custom_meta (List[str]): StorageStrategy type for each key
386388
387389 Returns:
388390 List[Any]: Retrieved values in the same order as input keys.
@@ -414,13 +416,29 @@ def get(self, keys: list[str], shapes=None, dtypes=None, custom_meta=None) -> li
414416
415417 return results
416418
417- def clear (self , keys : list [str ]):
419+ def clear (self , keys : list [str ], custom_meta = None ):
418420 """Deletes multiple keys from remote storage.
419421
420422 Args:
421423 keys (List[str]): List of keys to remove.
424+ custom_meta (List[str]): StorageStrategy type for each key
422425 """
423- pass
426+ if not isinstance (keys , list ):
427+ raise ValueError ("keys must be a list" )
428+ if not isinstance (custom_meta , list ):
429+ raise ValueError ("custom_meta must be a list if provided" )
430+ if len (custom_meta ) != len (keys ):
431+ raise ValueError ("custom_meta length must match keys" )
432+
433+ routed_indexes = self ._route_to_strategies (
434+ custom_meta , lambda strategy_ , item_ : strategy_ .supports_clear (item_ )
435+ )
436+ # Todo(dpj): Parallel clear
437+ for strategy , indexes in routed_indexes .items ():
438+ if not indexes :
439+ continue
440+ strategy_keys = [keys [i ] for i in indexes ]
441+ strategy .clear (strategy_keys )
424442
425443 def _route_to_strategies (
426444 self ,
0 commit comments