Browse Source

Fix google cloud session manager (#3942)

tofarr 1 year ago
parent
commit
31dbd3d02e
2 changed files with 7 additions and 3 deletions
  1. 1 1
      openhands/storage/__init__.py
  2. 6 2
      openhands/storage/google_cloud.py

+ 1 - 1
openhands/storage/__init__.py

@@ -13,5 +13,5 @@ def get_file_store(file_store: str, file_store_path: str | None = None) -> FileS
     elif file_store == 's3':
         return S3FileStore()
     elif file_store == 'google_cloud':
-        return GoogleCloudFileStore()
+        return GoogleCloudFileStore(file_store_path)
     return InMemoryFileStore()

+ 6 - 2
openhands/storage/google_cloud.py

@@ -1,6 +1,7 @@
 import os
 from typing import List, Optional
 
+from google.api_core.exceptions import NotFound
 from google.cloud import storage
 
 from openhands.storage.files import FileStore
@@ -25,8 +26,11 @@ class GoogleCloudFileStore(FileStore):
 
     def read(self, path: str) -> str:
         blob = self.bucket.blob(path)
-        with blob.open('r') as f:
-            return f.read()
+        try:
+            with blob.open('r') as f:
+                return f.read()
+        except NotFound as err:
+            raise FileNotFoundError(err)
 
     def list(self, path: str) -> List[str]:
         if not path or path == '/':