refactor: Storage 改用工厂模式,server reload 接入 uvicorn

- 新增 StorageFactory(BaseFactory[BaseStorage]) 替代手写 dict 注册
- H5Storage / JSONStorage 通过 @StorageFactory.register 注册
- dataset.py 使用 StorageFactory.create() 替代 create_storage()
- 删除 create_storage / available_storage_types 死函数
- server.py reload 参数正式传入 uvicorn.run()
This commit is contained in:
2026-05-16 17:00:26 +08:00
parent 48a53121ba
commit 04c0dc7a47
5 changed files with 30 additions and 42 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ from torch.utils.data import Dataset
from astrai.dataset.storage import (
BaseStorage,
create_storage,
StorageFactory,
detect_format,
)
from astrai.factory import BaseFactory
@@ -42,7 +42,7 @@ class BaseDataset(Dataset, ABC):
"""
if storage_type is None:
storage_type = detect_format(load_path)
self.storage = create_storage(storage_type)
self.storage = StorageFactory.create(storage_type)
self.storage.load(load_path, tokenizer=tokenizer)
def load_json(self, load_path: str, tokenizer=None):