File size: 789 Bytes
dfb775d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""StorageProvider — uniform interface across local fs / HF Hub / Lighthouse / IPFS.

Canonical mindxtrain2.md §Part 4 `storage.provider`. Concrete implementations
live alongside (`local_fs`, `hf_hub`, `lighthouse`, `ipfs`). Selected at
runtime via `cfg.publish.storage_provider`.
"""

from __future__ import annotations

from abc import ABC, abstractmethod
from pathlib import Path

from pydantic import BaseModel, ConfigDict


class StorageRef(BaseModel):
    model_config = ConfigDict(extra="forbid")

    provider: str
    uri: str


class StorageProvider(ABC):
    """Pluggable storage backend."""

    name: str

    @abstractmethod
    def put_dir(self, src: Path, key: str) -> StorageRef: ...

    @abstractmethod
    def get_dir(self, ref: StorageRef, dest: Path) -> Path: ...