added suggestions

This commit is contained in:
kahghi 2025-01-21 14:47:56 +08:00
parent 55cc127b03
commit b1887fef1b
3 changed files with 54 additions and 20 deletions

View File

@ -146,10 +146,12 @@ class GCSStorageProvider(StorageProvider):
def __init__(self):
self.bucket_name = GCS_BUCKET_NAME
if GCS_BUCKET_NAME and GOOGLE_APPLICATION_CREDENTIALS_JSON:
if GOOGLE_APPLICATION_CREDENTIALS_JSON:
self.gcs_client = storage.Client.from_service_account_info(info=json.loads(GOOGLE_APPLICATION_CREDENTIALS_JSON))
else:
# defaults to environment, be it GCE VM or user credentials
# if no credentials json is provided, credentials will be picked up from the environment
# if running on local environment, credentials would be user credentials
# if running on a Compute Engine instance, credentials would be from Google Metadata server
self.gcs_client = storage.Client()
self.bucket = self.gcs_client.bucket(GCS_BUCKET_NAME)
@ -206,7 +208,7 @@ def get_storage_provider(storage_provider: str):
Storage = LocalStorageProvider()
elif storage_provider == "s3":
Storage = S3StorageProvider()
elif storage_provider == "gcs":
elif storage_provider == "gcs" and GCS_BUCKET_NAME:
Storage = GCSStorageProvider()
else:
raise RuntimeError(f"Unsupported storage provider: {storage_provider}")

View File

@ -105,6 +105,7 @@ dependencies = [
"ldap3==2.9.1",
"google-cloud-storage==2.19.0",
"gcp-storage-emulator>=2024.8.3",
"pytest-env>=1.1.5",
]
readme = "README.md"
requires-python = ">= 3.11, < 3.13.0a1"
@ -126,6 +127,11 @@ open-webui = "open_webui:app"
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.pytest.ini_options]
env = [
"GCS_BUCKET_NAME=my-bucket"
]
[tool.rye]
managed = true
dev-dependencies = []

26
uv.lock
View File

@ -24,6 +24,9 @@ resolution-markers = [
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system == 'Darwin'",
"python_full_version < '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
@ -32,6 +35,10 @@ resolution-markers = [
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
@ -60,6 +67,10 @@ resolution-markers = [
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
@ -88,6 +99,7 @@ resolution-markers = [
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
]
[[package]]
@ -2850,6 +2862,7 @@ dependencies = [
{ name = "pypdf" },
{ name = "pytest" },
{ name = "pytest-docker" },
{ name = "pytest-env" },
{ name = "python-jose" },
{ name = "python-multipart" },
{ name = "python-pptx" },
@ -2935,6 +2948,7 @@ requires-dist = [
{ name = "pypdf", specifier = "==4.3.1" },
{ name = "pytest", specifier = "~=8.3.2" },
{ name = "pytest-docker", specifier = "~=3.1.1" },
{ name = "pytest-env", specifier = ">=1.1.5" },
{ name = "python-jose", specifier = "==3.3.0" },
{ name = "python-multipart", specifier = "==0.0.18" },
{ name = "python-pptx", specifier = "==1.0.0" },
@ -3940,6 +3954,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/1a/a4/69defc13bf77ee5aeb3e7b7c45393d6c7312e9c4d8b55d280a094ff76ff3/pytest_docker-3.1.1-py3-none-any.whl", hash = "sha256:fd0d48d6feac41f62acbc758319215ec9bb805c2309622afb07c27fa5c5ae362", size = 8243 },
]
[[package]]
name = "pytest-env"
version = "1.1.5"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pytest" },
]
sdist = { url = "https://files.pythonhosted.org/packages/1f/31/27f28431a16b83cab7a636dce59cf397517807d247caa38ee67d65e71ef8/pytest_env-1.1.5.tar.gz", hash = "sha256:91209840aa0e43385073ac464a554ad2947cc2fd663a9debf88d03b01e0cc1cf", size = 8911 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/de/b8/87cfb16045c9d4092cfcf526135d73b88101aac83bc1adcf82dfb5fd3833/pytest_env-1.1.5-py3-none-any.whl", hash = "sha256:ce90cf8772878515c24b31cd97c7fa1f4481cd68d588419fd45f10ecaee6bc30", size = 6141 },
]
[[package]]
name = "python-dateutil"
version = "2.9.0.post0"