mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
* add storage classes * add minio * add event stream storage * storage test working * use fixture * event stream test passing * better serialization * factor out serialization pkg * move more serialization * fix tests * fix test * remove __all__ * add rehydration test * add more rehydration test * fix fixture * fix dict init * update tests * lock * regenerate tests * Update opendevin/events/stream.py * revert tests * revert old integration tests * only add fields if present * regen tests * pin pyarrow * fix unit tests * remove cause from memories * revert tests * regen tests
28 lines
880 B
Python
28 lines
880 B
Python
import os
|
|
|
|
from minio import Minio
|
|
|
|
from .files import FileStore
|
|
|
|
AWS_S3_ENDPOINT = 's3.amazonaws.com'
|
|
|
|
|
|
class S3FileStore(FileStore):
|
|
def __init__(self, endpoint: str = AWS_S3_ENDPOINT) -> None:
|
|
access_key = os.getenv('AWS_ACCESS_KEY_ID')
|
|
secret_key = os.getenv('AWS_SECRET_ACCESS_KEY')
|
|
self.bucket = os.getenv('AWS_S3_BUCKET')
|
|
self.client = Minio(endpoint, access_key, secret_key)
|
|
|
|
def write(self, path: str, contents: str) -> None:
|
|
self.client.put_object(self.bucket, path, contents)
|
|
|
|
def read(self, path: str) -> str:
|
|
return self.client.get_object(self.bucket, path).data.decode('utf-8')
|
|
|
|
def list(self, path: str) -> list[str]:
|
|
return [obj.object_name for obj in self.client.list_objects(self.bucket, path)]
|
|
|
|
def delete(self, path: str) -> None:
|
|
self.client.remove_object(self.bucket, path)
|