Skip to content

Commit

Permalink
Fix google cloud session manager (#3942)
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr committed Sep 19, 2024
1 parent dd7174e commit 31dbd3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion openhands/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 6 additions & 2 deletions openhands/storage/google_cloud.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,8 +26,11 @@ def write(self, path: str, contents: str | bytes) -> None:

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 == '/':
Expand Down

0 comments on commit 31dbd3d

Please sign in to comment.