pycivitai.manager.dispatch

DispatchManager

class pycivitai.manager.dispatch.DispatchManager(root_dir: str, offline: bool = False)[source]

Management of all models.

__init__(root_dir: str, offline: bool = False)[source]

Manages multiple models and their versions downloaded from civitai.com.

Parameters:
  • root_dir – The root directory where the models will be managed.

  • offline – If True, the manager operates in offline mode, using locally downloaded resources.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

delete_model(model_name_or_id: Union[str, int])[source]

Delete the specified model and all its versions from the local storage.

Parameters:

model_name_or_id (Union[str, int]) – The name or ID of the model to delete.

Raises:

LocalModelNotFound – If the specified model is not found locally.

delete_version(model_name_or_id: Union[str, int], version: Union[str, int])[source]

Delete the specified version of the model from the local storage.

Parameters:
  • model_name_or_id (Union[str, int]) – The name or ID of the model.

  • version (Union[str, int]) – The version ID or name to delete.

get_file(model_name_or_id: Union[str, int], version: Optional[Union[int, str]] = None, pattern: Optional[str] = None, creator: Optional[str] = None)[source]

Get the local file path of the specified model file.

Parameters:
  • model_name_or_id (Union[str, int]) – The name or ID of the model to manage.

  • version (Union[str, int, None]) – The version ID or name of the model version. If None, the latest version is used.

  • pattern (str) – The pattern or name of the file to get. If None, the primary file will be returned.

  • creator (Optional[str]) – Name of creator. None means anyone.

Returns:

The local path of the specified model file.

Return type:

str

Raises:
list_models() List[ModelManager][source]

List all the local models managed by this DispatchManager.

Returns:

A list of ModelManager objects, one for each model.

Return type:

List[ModelManager]

property total_size: int

Get the total size of all the local model files managed by this DispatchManager.

Returns:

The total size in bytes.

Return type:

int

LocalModelNotFound

exception pycivitai.manager.dispatch.LocalModelNotFound[source]

LocalModelDuplicated

exception pycivitai.manager.dispatch.LocalModelDuplicated[source]