initial work on s3, config is shared between client and server

This commit is contained in:
Christoph Stahl 2022-11-10 20:59:21 +01:00
parent 7d9dfe2e62
commit 2a72e842e3
2 changed files with 53 additions and 0 deletions

20
pyproject.toml Normal file
View file

@ -0,0 +1,20 @@
[tool.poetry]
name = "syng"
version = "2.0.0"
description = ""
authors = ["Christoph Stahl <christoph.stahl@tu-dortmund.de>"]
license = "GPL3"
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.7"
pytube = "^12.1.0"
aiohttp = "^3.8.3"
python-mpv = "^1.0.1"
python-socketio = "^5.7.2"
minio = "^7.1.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

33
syng/sources/s3.py Normal file
View file

@ -0,0 +1,33 @@
from minio import Minio
from time import perf_counter
from .source import Source, async_in_thread, available_sources
from ..result import Result
class S3Source(Source):
def __init__(self, config):
super().__init__()
self.minio = Minio(
config["s3_endpoint"],
access_key=config["access_key"],
secret_key=config["secret_key"],
)
self.bucket = config["bucket"]
def init_server(self):
print("Start indexing")
start = perf_counter()
self.index = list(self.minio.list_objects("bucket"))
stop = perf_counter()
print(f"Took {stop - start:0.4f} seconds")
@async_in_thread
def search(self, query: str) -> list[Result]:
pass
async def build_index():
pass
available_sources["s3"] = S3Source