Browse Source

added suggestions

kahghi 3 months ago
parent
commit
b1887fef1b
3 changed files with 54 additions and 20 deletions
  1. 5 3
      backend/open_webui/storage/provider.py
  2. 23 17
      pyproject.toml
  3. 26 0
      uv.lock

+ 5 - 3
backend/open_webui/storage/provider.py

@@ -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}")

+ 23 - 17
pyproject.toml

@@ -13,17 +13,17 @@ dependencies = [
 
     "Flask==3.1.0",
     "Flask-Cors==5.0.0",
-    
+
     "python-socketio==5.11.3",
     "python-jose==3.3.0",
     "passlib[bcrypt]==1.7.4",
-    
+
     "requests==2.32.3",
     "aiohttp==3.11.8",
     "async-timeout",
     "aiocache",
     "aiofiles",
-    
+
     "sqlalchemy==2.0.32",
     "alembic==1.14.0",
     "peewee==3.17.8",
@@ -32,33 +32,33 @@ dependencies = [
     "pgvector==0.3.5",
     "PyMySQL==1.1.1",
     "bcrypt==4.2.0",
-    
+
     "pymongo",
     "redis",
     "boto3==1.35.53",
-    
+
     "argon2-cffi==23.1.0",
     "APScheduler==3.10.4",
-    
+
     "openai",
     "anthropic",
     "google-generativeai==0.7.2",
     "tiktoken",
-    
+
     "langchain==0.3.7",
     "langchain-community==0.3.7",
-    
+
     "fake-useragent==1.5.1",
     "chromadb==0.6.2",
     "pymilvus==2.5.0",
     "qdrant-client~=1.12.0",
     "opensearch-py==2.7.1",
-    
+
     "transformers",
     "sentence-transformers==3.3.1",
     "colbert-ai==0.2.21",
     "einops==0.8.0",
-    
+
     "ftfy==6.2.3",
     "pypdf==4.3.1",
     "fpdf2==2.8.2",
@@ -77,34 +77,35 @@ dependencies = [
     "psutil",
     "sentencepiece",
     "soundfile==0.12.1",
-    
+
     "opencv-python-headless==4.10.0.84",
     "rapidocr-onnxruntime==1.3.24",
     "rank-bm25==0.2.2",
-    
+
     "faster-whisper==1.0.3",
-    
+
     "PyJWT[crypto]==2.10.1",
     "authlib==1.3.2",
-    
+
     "black==24.8.0",
     "langfuse==2.44.0",
     "youtube-transcript-api==0.6.3",
     "pytube==15.0.0",
-    
+
     "extract_msg",
     "pydub",
     "duckduckgo-search~=6.3.5",
-    
+
     "docker~=7.1.0",
     "pytest~=8.3.2",
     "pytest-docker~=3.1.1",
     "moto[s3]>=5.0.26",
-    
+
     "googleapis-common-protos==1.63.2",
     "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 - 0
uv.lock

@@ -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"