S3 Storage: Use STANDARD tier for small objects (#4453)
This commit is contained in:
@@ -113,7 +113,7 @@ class S3Storage(BaseStorage):
|
|||||||
uri = uri.replace(f".{file_ext}", f".{file_ext}.zst")
|
uri = uri.replace(f".{file_ext}", f".{file_ext}.zst")
|
||||||
artifact.uri = uri
|
artifact.uri = uri
|
||||||
|
|
||||||
sc = await self._get_storage_class_for_org(artifact.organization_id, self.bucket)
|
sc = await self._get_storage_class_for_org(artifact.organization_id, self.bucket, len(data))
|
||||||
tags = await self._get_tags_for_org(artifact.organization_id)
|
tags = await self._get_tags_for_org(artifact.organization_id)
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Storing artifact",
|
"Storing artifact",
|
||||||
@@ -125,7 +125,12 @@ class S3Storage(BaseStorage):
|
|||||||
)
|
)
|
||||||
await self.async_client.upload_file(uri, data, storage_class=sc, tags=tags)
|
await self.async_client.upload_file(uri, data, storage_class=sc, tags=tags)
|
||||||
|
|
||||||
async def _get_storage_class_for_org(self, organization_id: str, bucket: str) -> S3StorageClass:
|
async def _get_storage_class_for_org(
|
||||||
|
self,
|
||||||
|
organization_id: str,
|
||||||
|
bucket: str,
|
||||||
|
object_size_bytes: int | None = None,
|
||||||
|
) -> S3StorageClass:
|
||||||
return S3StorageClass.STANDARD
|
return S3StorageClass.STANDARD
|
||||||
|
|
||||||
async def _get_tags_for_org(self, organization_id: str) -> dict[str, str]:
|
async def _get_tags_for_org(self, organization_id: str) -> dict[str, str]:
|
||||||
@@ -147,7 +152,7 @@ class S3Storage(BaseStorage):
|
|||||||
return await self.async_client.create_presigned_urls([artifact.uri for artifact in artifacts])
|
return await self.async_client.create_presigned_urls([artifact.uri for artifact in artifacts])
|
||||||
|
|
||||||
async def store_artifact_from_path(self, artifact: Artifact, path: str) -> None:
|
async def store_artifact_from_path(self, artifact: Artifact, path: str) -> None:
|
||||||
sc = await self._get_storage_class_for_org(artifact.organization_id, self.bucket)
|
sc = await self._get_storage_class_for_org(artifact.organization_id, self.bucket, os.path.getsize(path))
|
||||||
tags = await self._get_tags_for_org(artifact.organization_id)
|
tags = await self._get_tags_for_org(artifact.organization_id)
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Storing artifact from path",
|
"Storing artifact from path",
|
||||||
|
|||||||
@@ -36,7 +36,12 @@ class S3StorageForTests(S3Storage):
|
|||||||
async def _get_tags_for_org(self, organization_id: str) -> dict[str, str]:
|
async def _get_tags_for_org(self, organization_id: str) -> dict[str, str]:
|
||||||
return {"dummy": f"org-{organization_id}", "test": "jerry"}
|
return {"dummy": f"org-{organization_id}", "test": "jerry"}
|
||||||
|
|
||||||
async def _get_storage_class_for_org(self, organization_id: str, bucket: str) -> S3StorageClass:
|
async def _get_storage_class_for_org(
|
||||||
|
self,
|
||||||
|
organization_id: str,
|
||||||
|
bucket: str,
|
||||||
|
object_size_bytes: int | None = None,
|
||||||
|
) -> S3StorageClass:
|
||||||
return S3StorageClass.ONEZONE_IA
|
return S3StorageClass.ONEZONE_IA
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user