|
7 | 7 | from common_library.json_serialization import json_dumps |
8 | 8 | from fastapi import FastAPI |
9 | 9 | from pydantic import TypeAdapter |
10 | | -from servicelib.logging_utils import log_context |
11 | 10 | from tenacity import retry, wait_random_exponential |
12 | 11 | from tenacity.asyncio import AsyncRetrying |
13 | 12 | from tenacity.before_sleep import before_sleep_log |
|
29 | 28 | async def _ensure_s3_bucket( |
30 | 29 | client: SimcoreS3API, settings: ApplicationSettings |
31 | 30 | ) -> None: |
32 | | - with log_context(_logger, logging.DEBUG, msg="setup.s3_bucket.cleanup_ctx"): |
33 | | - assert settings.STORAGE_S3 # nosec |
34 | | - if await client.bucket_exists(bucket=settings.STORAGE_S3.S3_BUCKET_NAME): |
35 | | - _logger.info( |
36 | | - "S3 bucket %s exists already, skipping creation", |
37 | | - settings.STORAGE_S3.S3_BUCKET_NAME, |
38 | | - ) |
39 | | - return |
40 | | - await client.create_bucket( |
41 | | - bucket=settings.STORAGE_S3.S3_BUCKET_NAME, |
42 | | - region=TypeAdapter( |
43 | | - BucketLocationConstraintType | Literal["us-east-1"] |
44 | | - ).validate_python(settings.STORAGE_S3.S3_REGION), |
| 31 | + assert settings.STORAGE_S3 # nosec |
| 32 | + if await client.bucket_exists(bucket=settings.STORAGE_S3.S3_BUCKET_NAME): |
| 33 | + _logger.info( |
| 34 | + "S3 bucket %s exists already, skipping creation", |
| 35 | + settings.STORAGE_S3.S3_BUCKET_NAME, |
45 | 36 | ) |
| 37 | + return |
| 38 | + await client.create_bucket( |
| 39 | + bucket=settings.STORAGE_S3.S3_BUCKET_NAME, |
| 40 | + region=TypeAdapter( |
| 41 | + BucketLocationConstraintType | Literal["us-east-1"] |
| 42 | + ).validate_python(settings.STORAGE_S3.S3_REGION), |
| 43 | + ) |
46 | 44 |
|
47 | 45 |
|
48 | 46 | def setup_s3(app: FastAPI) -> None: |
|
0 commit comments