pycivitai.manager.version
VersionManager
- class pycivitai.manager.version.VersionManager(root_dir: str, model_name_or_id: Union[str, int], creator: Optional[str], version: Union[str, int], model_data: Optional[dict] = None, offline: bool = False)[source]
Management of specific version of model.
- __init__(root_dir: str, model_name_or_id: Union[str, int], creator: Optional[str], version: Union[str, int], model_data: Optional[dict] = None, offline: bool = False)[source]
Manages the local model files downloaded from civitai.com for a specific model and version.
- Parameters:
root_dir – The root directory where the model files will be managed.
model_name_or_id – The name or ID of the model to manage files for.
creator – Name of creator.
None
means anyone.version – The version ID or name to manage files for.
model_data – Optional dictionary containing model information to avoid fetching it from the API.
offline – If True, the manager operates in offline mode, using locally downloaded resources.
- __weakref__
list of weak references to the object (if defined)
- delete_file(filename)[source]
Delete the specified model file from the local storage.
- Parameters:
filename (str) – The name of the file to delete.
- Raises:
LocalFileNotFound – If the specified file is not found locally.
- get_file(pattern: Optional[str] = None)[source]
Get the local file path of the specified model file.
- Parameters:
pattern (str) – The pattern or name of the file to get. If None, the primary file will be returned.
- Returns:
The local path of the specified model file.
- Return type:
str
- Raises:
LocalPrimaryFileUnset – If the primary file is not set and no specific pattern is provided.
LocalFileNotFound – If the specified file is not found locally.
LocalFileDuplicated – If multiple files matching the pattern are found locally.
- list_files() List[LocalFile] [source]
List all the local model files associated with this version manager.
- Returns:
A list of LocalFile objects containing information about each local model file.
- Return type:
List[LocalFile]
- property total_size: int
Get the total size of all the local model files associated with this version manager.
- Returns:
The total size in bytes.
- Return type:
int