Skip to content

Commit 6660773

Browse files
committed
fix: Reflect feedback
1 parent 669884b commit 6660773

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/ai/backend/common/artifact_storage.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABC, abstractmethod
22
from dataclasses import dataclass
3-
from typing import Any, Protocol
3+
from typing import Any
44

55
from ai.backend.common.data.storage.registries.types import ModelTarget
66
from ai.backend.common.data.storage.types import ArtifactStorageImportStep
@@ -30,25 +30,30 @@ async def get_file_info(self, filepath: str) -> Any:
3030
raise NotImplementedError
3131

3232

33-
class StoragePoolProtocol(Protocol):
34-
"""Protocol for StoragePool interface"""
33+
class AbstractStoragePool(ABC):
34+
"""Abstract base class for storage pool interface"""
3535

36+
@abstractmethod
3637
def get_storage(self, name: str) -> AbstractStorage:
3738
"""Get storage by name"""
3839
...
3940

41+
@abstractmethod
4042
def add_storage(self, name: str, storage: AbstractStorage) -> None:
4143
"""Add a storage to the pool"""
4244
...
4345

46+
@abstractmethod
4447
def remove_storage(self, name: str) -> None:
4548
"""Remove a storage from the pool"""
4649
...
4750

51+
@abstractmethod
4852
def list_storages(self) -> list[str]:
4953
"""List all storage names in the pool"""
5054
...
5155

56+
@abstractmethod
5257
def has_storage(self, name: str) -> bool:
5358
"""Check if storage exists in the pool"""
5459
...
@@ -60,6 +65,6 @@ class ImportStepContext:
6065

6166
model: ModelTarget
6267
registry_name: str
63-
storage_pool: StoragePoolProtocol
68+
storage_pool: AbstractStoragePool
6469
storage_step_mappings: dict[ArtifactStorageImportStep, str]
6570
step_metadata: dict[str, Any] # For passing data between steps

src/ai/backend/storage/services/artifacts/huggingface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import aiohttp
1414

15-
from ai.backend.common.artifact_storage import StoragePoolProtocol
15+
from ai.backend.common.artifact_storage import AbstractStoragePool
1616
from ai.backend.common.bgtask.bgtask import BackgroundTaskManager, ProgressReporter
1717
from ai.backend.common.data.artifact.types import ArtifactRegistryType
1818
from ai.backend.common.data.storage.registries.types import (
@@ -795,7 +795,7 @@ async def _download_file_to_storage(
795795
file_info: FileObjectData,
796796
model: ModelTarget,
797797
storage_name: str,
798-
storage_pool: StoragePoolProtocol,
798+
storage_pool: AbstractStoragePool,
799799
download_chunk_size: int,
800800
) -> str:
801801
"""Download file from HuggingFace to specified storage"""

src/ai/backend/storage/services/artifacts/reservoir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import aiofiles
1313

14-
from ai.backend.common.artifact_storage import AbstractStorage, StoragePoolProtocol
14+
from ai.backend.common.artifact_storage import AbstractStorage, AbstractStoragePool
1515
from ai.backend.common.bgtask.bgtask import BackgroundTaskManager, ProgressReporter
1616
from ai.backend.common.data.artifact.types import ArtifactRegistryType
1717
from ai.backend.common.data.storage.registries.types import FileObjectData, ModelTarget
@@ -581,7 +581,7 @@ async def _handle_object_storage_download(
581581
return downloaded_files, bytes_copied
582582

583583
def _get_s3_client(
584-
self, storage_pool: StoragePoolProtocol, storage_name: str
584+
self, storage_pool: AbstractStoragePool, storage_name: str
585585
) -> tuple[S3Client, str]:
586586
"""Get S3 client for the specified storage"""
587587
# Get storage from pool and verify it's ObjectStorage type
@@ -617,7 +617,7 @@ async def _stream_bucket_to_bucket(
617617
self,
618618
source_cfg: ReservoirConfig,
619619
storage_name: str,
620-
storage_pool: StoragePoolProtocol,
620+
storage_pool: AbstractStoragePool,
621621
options: BucketCopyOptions,
622622
progress_reporter: Optional[ProgressReporter],
623623
key_prefix: Optional[str] = None,

src/ai/backend/storage/storages/storage_pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from typing import Optional, Self
33

4-
from ai.backend.common.artifact_storage import AbstractStorage
4+
from ai.backend.common.artifact_storage import AbstractStorage, AbstractStoragePool
55
from ai.backend.common.data.storage.types import ArtifactStorageType
66
from ai.backend.common.exception import GenericNotImplementedError, InvalidConfigError
77
from ai.backend.logging.utils import BraceStyleAdapter
@@ -14,7 +14,7 @@
1414
log = BraceStyleAdapter(logging.getLogger(__spec__.name))
1515

1616

17-
class StoragePool:
17+
class StoragePool(AbstractStoragePool):
1818
"""
1919
Storage pool that manages different types of storage backends.
2020
Supports both Object Storage (S3-compatible) and VFS storage.

0 commit comments

Comments
 (0)