From 2a72e842e3e963c1f22c65a287976a93450d4d82 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Thu, 10 Nov 2022 20:59:21 +0100 Subject: [PATCH] initial work on s3, config is shared between client and server --- pyproject.toml | 20 ++++++++++++++++++++ syng/sources/s3.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 pyproject.toml create mode 100644 syng/sources/s3.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2420894 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "syng" +version = "2.0.0" +description = "" +authors = ["Christoph Stahl "] +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" diff --git a/syng/sources/s3.py b/syng/sources/s3.py new file mode 100644 index 0000000..0a55709 --- /dev/null +++ b/syng/sources/s3.py @@ -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