Skip to content

Commit 65b41c1

Browse files
authored
Merge pull request #3 from Querent-ai/storage_base
[Storage] setup storage base
2 parents d155785 + 23aa855 commit 65b41c1

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

querent/storage/storage_base.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from abc import ABC, abstractmethod
2+
from typing import Optional
3+
from pathlib import Path
4+
from asyncio import AbstractWriter
5+
6+
class Storage(ABC):
7+
@abstractmethod
8+
async def check_connectivity(self) -> None:
9+
pass
10+
11+
@abstractmethod
12+
async def put(self, path: Path, payload) -> None:
13+
pass
14+
15+
@abstractmethod
16+
async def copy_to(self, path: Path, output: AbstractWriter) -> None:
17+
pass
18+
19+
async def copy_to_file(self, path: Path, output_path: Path) -> None:
20+
async with open(output_path, "wb") as output_file:
21+
await self.copy_to(path, output_file)
22+
23+
@abstractmethod
24+
async def get_slice(self, path: Path, start: int, end: int) -> bytes:
25+
pass
26+
27+
@abstractmethod
28+
async def get_all(self, path: Path) -> bytes:
29+
pass
30+
31+
@abstractmethod
32+
async def delete(self, path: Path) -> None:
33+
pass
34+
35+
@abstractmethod
36+
async def bulk_delete(self, paths: list[Path]) -> None:
37+
pass
38+
39+
@abstractmethod
40+
async def exists(self, path: Path) -> bool:
41+
pass
42+
43+
@abstractmethod
44+
async def file_num_bytes(self, path: Path) -> int:
45+
pass
46+
47+
@property
48+
@abstractmethod
49+
def uri(self) -> str:
50+
pass

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,4 @@ EbookLib==0.18
153153
html2text==2020.1.16
154154
duckduckgo-search==3.8.3
155155
google-generativeai==0.1.0
156+
asyncio==3.4.3

0 commit comments

Comments
 (0)