Warnings fixed: - datetime.utcnow() → datetime.now(UTC) across 48+ files (src/ + tests/) - datetime.utcnow (callback ref) → lambda: datetime.now(UTC) in model fields (18 files) - Pydantic class Config → model_config = ConfigDict(...) (16 files) - Pydantic .dict() → .model_dump() (8 files) - ConfigDict(allow_population_by_field_name=True) → validate_by_name=True - SQLAlchemy declarative_base() import path updated - FastAPI on_event → lifespan context manager (app.py) - Import sorting (ruff I001) auto-fixed across all files - Fixed broken re-export chains that ruff F401 cleanup broke: _validate_bcp47: service.py now imports from dictionary_validation directly job_to_response: _job_routes.py and test imports from service_utils directly fetch_datasource_metadata: restored re-export in service.py - Added missing TranslateJobService import in _job_routes.py (was deleted by F401) - Added ConfigDict(protected_namespaces=()) for DashboardDatasetItem schema field - pytest.ini: replaced deprecated importmode with asyncio_mode All 440 tests pass with zero deprecation warnings.
39 lines
2.0 KiB
Python
39 lines
2.0 KiB
Python
# #region StorageModels [TYPE Module] [SEMANTICS pydantic, storage, model, backup, config]
|
|
# @RATIONALE Fixed typo 'repositorys' → 'repositories' in FileCategory.REPOSITORY and StorageConfig.repo_path default. Breaking change documented for existing installations.
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# #region FileCategory [C:1] [TYPE Class]
|
|
# @BRIEF Enumeration of supported file categories in the storage system.
|
|
class FileCategory(str, Enum):
|
|
BACKUP = "backups"
|
|
REPOSITORY = "repositories"
|
|
# #endregion FileCategory
|
|
|
|
# #region StorageConfig [C:1] [TYPE Class]
|
|
# @BRIEF Configuration model for the storage system, defining paths and naming patterns.
|
|
class StorageConfig(BaseModel):
|
|
root_path: str = Field(default="/app/storage", description="Absolute path to the storage root directory.")
|
|
backup_path: str = Field(default="backups", description="Subpath for backups.")
|
|
repo_path: str = Field(default="repositories", description="Subpath for repositories.")
|
|
backup_structure_pattern: str = Field(default="{category}/", description="Pattern for backup directory structure.")
|
|
repo_structure_pattern: str = Field(default="{category}/", description="Pattern for repository directory structure.")
|
|
filename_pattern: str = Field(default="{name}_{timestamp}", description="Pattern for filenames.")
|
|
# #endregion StorageConfig
|
|
|
|
# #region StoredFile [C:1] [TYPE Class]
|
|
# @BRIEF Data model representing metadata for a file stored in the system.
|
|
class StoredFile(BaseModel):
|
|
name: str = Field(..., description="Name of the file (including extension).")
|
|
path: str = Field(..., description="Relative path from storage root.")
|
|
size: int = Field(..., ge=0, description="Size of the file in bytes.")
|
|
created_at: datetime = Field(..., description="Creation timestamp.")
|
|
category: FileCategory = Field(..., description="Category of the file.")
|
|
mime_type: str | None = Field(None, description="MIME type of the file.")
|
|
# #endregion StoredFile
|
|
# #endregion StorageModels
|
|
|