diff --git a/.github/workflows/test_s3_file_storage.yml b/.github/workflows/test_s3_file_storage.yml index 5ef72f728..8035a9bc3 100644 --- a/.github/workflows/test_s3_file_storage.yml +++ b/.github/workflows/test_s3_file_storage.yml @@ -23,8 +23,11 @@ jobs: env: STORAGE_BACKEND: s3 ENABLE_BACKEND_ACCESS_CONTROL: True + AWS_REGION: eu-west-1 + AWS_ENDPOINT_URL: https://s3-eu-west-1.amazonaws.com AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_DEV_USER_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_DEV_USER_SECRET_KEY }} + STORAGE_BUCKET_NAME: github-runner-cognee-tests LLM_MODEL: ${{ secrets.LLM_MODEL }} LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} LLM_API_KEY: ${{ secrets.LLM_API_KEY }} diff --git a/cognee/infrastructure/files/storage/S3FileStorage.py b/cognee/infrastructure/files/storage/S3FileStorage.py index 4d71c83fd..7c5a1033c 100644 --- a/cognee/infrastructure/files/storage/S3FileStorage.py +++ b/cognee/infrastructure/files/storage/S3FileStorage.py @@ -26,7 +26,8 @@ class S3FileStorage(Storage): key=s3_config.aws_access_key_id, secret=s3_config.aws_secret_access_key, anon=False, - endpoint_url="https://s3-eu-west-1.amazonaws.com", + endpoint_url=s3_config.aws_endpoint_url, + client_kwargs={"region_name": s3_config.aws_region}, ) else: raise ValueError("S3 credentials are not set in the configuration.") diff --git a/cognee/infrastructure/files/storage/s3_config.py b/cognee/infrastructure/files/storage/s3_config.py index dc08e3333..0b9372b7e 100644 --- a/cognee/infrastructure/files/storage/s3_config.py +++ b/cognee/infrastructure/files/storage/s3_config.py @@ -4,6 +4,8 @@ from pydantic_settings import BaseSettings, SettingsConfigDict class S3Config(BaseSettings): + aws_region: Optional[str] = None + aws_endpoint_url: Optional[str] = None aws_access_key_id: Optional[str] = None aws_secret_access_key: Optional[str] = None model_config = SettingsConfigDict(env_file=".env", extra="allow") diff --git a/cognee/tests/test_s3_file_storage.py b/cognee/tests/test_s3_file_storage.py index f16063777..3a20b232c 100755 --- a/cognee/tests/test_s3_file_storage.py +++ b/cognee/tests/test_s3_file_storage.py @@ -13,10 +13,11 @@ logger = get_logger() async def main(): + bucket_name = os.getenv("STORAGE_BUCKET_NAME") test_run_id = uuid4() - data_directory_path = f"s3://cognee-storage-dev/{test_run_id}/data" + data_directory_path = f"s3://{bucket_name}/{test_run_id}/data" cognee.config.data_root_directory(data_directory_path) - cognee_directory_path = f"s3://cognee-storage-dev/{test_run_id}/system" + cognee_directory_path = f"s3://{bucket_name}/{test_run_id}/system" cognee.config.system_root_directory(cognee_directory_path) await cognee.prune.prune_data()