voxkit.storage
Persistence and CRUD operations for voxkit assets which belong in local storage per user.
Submodules
- datasets: Dataset CRUD and validation
- models: Model management and import/export
- alignments: Alignment creation and tracking
- utils: ID generation and path management
Storage Structure
~/.voxkit/
├── datasets/{dataset_id}/
│ ├── voxkit_dataset.json
│ ├── alignments/{alignment_id}/
│ └── cache/
└── {engine_id}/train/{model_id}/
├── voxkit_model.json
└── entrypoint.model
Notes
- IDs are unique timestamps (YYYYMMDD_HHMMSS_ffffff)
- Storage root is created on first access, or in the startup routine
- Failed operations clean up partial changes
1"""Persistence and CRUD operations for voxkit assets which belong in local storage per user. 2 3Submodules 4---------- 5- **datasets**: Dataset CRUD and validation 6- **models**: Model management and import/export 7- **alignments**: Alignment creation and tracking 8- **utils**: ID generation and path management 9 10Storage Structure 11----------------- 12 13 ~/.voxkit/ 14 ├── datasets/{dataset_id}/ 15 │ ├── voxkit_dataset.json 16 │ ├── alignments/{alignment_id}/ 17 │ └── cache/ 18 └── {engine_id}/train/{model_id}/ 19 ├── voxkit_model.json 20 └── entrypoint.model 21 22Notes 23----- 24- IDs are unique timestamps (YYYYMMDD_HHMMSS_ffffff) 25- Storage root is created on first access, or in the startup routine 26- Failed operations clean up partial changes 27""" 28 29import logging 30 31# Import utils but don't call get_storage_root() at module import time 32from . import alignments, datasets, models, utils 33 34 35def _ensure_storage_root(): 36 """Ensure storage root directory exists. Called lazily when needed. 37 38 Returns: 39 Path: Path to the storage root directory 40 41 Raises: 42 Exception: If storage root cannot be created or accessed 43 """ 44 try: 45 from pathlib import Path 46 47 storage_root = Path(utils.get_storage_root()) 48 if not storage_root.exists(): 49 storage_root.mkdir(parents=True, exist_ok=True) 50 return storage_root 51 except Exception as e: 52 logging.getLogger(__name__).exception("Error initializing storage root") 53 raise e 54 55 56_ensure_storage_root() 57 58__all__ = ["alignments", "datasets", "models", "utils"]