Removal¶
modelmap.removal
¶
Removing a record: what would go, and doing it once confirmed.
Nothing leaves the disk that the plan did not list. A plan is one of:
tool: the store's own tool removes the record. In Ollama and the Hugging Face cache the model is the unit of deletion, and deleting a blob by hand leaves manifests or links pointing at nothing. The syntax was read fromollama rm --help(Ollama 0.40) andhf cache rm --help(hf 2.4.0), and thehfforms were run with--dry-runon a real cache.trash: the record's files, or its folder, move to the Trash. A folder moves whole only when every entry in it is one of the record's files; otherwise the listed files move one by one and the rest stays.refuse: nothing is done, and the note says why.
Paths to move are built from the record's folder and each file's label, never from a resolved path: a file reached through a symlink must not take the other store's file with it. A record whose files are used by another record is refused for the same reason.
ollama rm has no store argument; it acts on the running Ollama. It is
offered only for records in the Ollama provider's own store, only when
OLLAMA_HOST names this machine, and only when the running Ollama lists
every tag with the ID of the manifest in the scanned store: an Ollama using
another models folder could share tag names and remove its own copy.
Afterward the removal counts only if Ollama no longer lists the tags and
the scanned store no longer holds them.
Plan(record, action, note, argv=list(), paths=list(), variants=list(), store='')
dataclass
¶
What removing a record would do.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
ModelRecord
|
The record. |
required |
action
|
str
|
|
required |
note
|
str
|
One sentence for a person: what happens, or why not. |
required |
argv
|
list[str]
|
The command a |
list()
|
paths
|
list[str]
|
The files or folder a |
list()
|
variants
|
list[str]
|
Ollama tags removed with the record that share its
weights but differ in their settings; some may have been made with
|
list()
|
store
|
str
|
For an |
''
|
execute(plan, env)
¶
Carry out a tool or trash plan and check that it worked.
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
Whether the record's files are gone, and what went wrong if not. |
Source code in src/modelmap/removal.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
find(records, target)
¶
The records a target names: provider:name, a path, or a name.
An Ollama tag names the record it is an alias of. Several matches mean the target is ambiguous.
Source code in src/modelmap/removal.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
plan(record, ollama_stores=(), *, env=None, check_disk=True, home='~')
¶
Work out how a record would be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
ModelRecord
|
The record. |
required |
ollama_stores
|
Collection[str]
|
Resolved directories of the running Ollama's stores, as the Ollama provider found them. |
()
|
env
|
Mapping[str, str] | None
|
Environment whose |
None
|
check_disk
|
bool
|
Look at the disk and ask the tools. False to describe the plan only, as in a page made from an inventory. |
True
|
home
|
str
|
The home folder of the machine scanned; never moved whole. |
'~'
|
Source code in src/modelmap/removal.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
plan_digest(step)
¶
A fingerprint of everything a plan would do and the files it covers.
modelmap serve shows a plan, then plans again from a new scan before
acting; the two digests must match, so what goes is what was shown.
Source code in src/modelmap/removal.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
target_of(record, records)
¶
The shortest target that names this record and no other.
Source code in src/modelmap/removal.py
397 398 399 400 401 | |
trash_command(env)
¶
The command that moves files to the Trash, or None if there is none.
macOS has /usr/bin/trash; on Linux the trash of trash-cli or
gio trash from GLib.
Source code in src/modelmap/removal.py
91 92 93 94 95 96 97 98 99 100 101 | |