| 36 | return self._async_storage |
| 37 | |
| 38 | async def read(self, batch_size: Optional[int] = None, **kwargs) -> List: |
| 39 | batch_size = self.read_batch_size if batch_size is None else batch_size |
| 40 | if self.wrap_in_ray: |
| 41 | try: |
| 42 | return await self.storage.read.remote(batch_size, **kwargs) |
| 43 | except (StopIteration, StopAsyncIteration): |
| 44 | raise StopAsyncIteration() |
| 45 | except Exception as e: |
| 46 | if "StopAsyncIteration" in traceback.format_exc(): |
| 47 | raise StopAsyncIteration() from e |
| 48 | raise |
| 49 | else: |
| 50 | storage = await self._get_async_storage() |
| 51 | return await storage.read(batch_size, **kwargs) |
| 52 | |
| 53 | def state_dict(self) -> Dict: |
| 54 | return {"current_index": 0} |