Skip to content

Records

modelmap.records

The scan result: what was found, where, and what went wrong.

A :class:Scan serializes to JSON so an inventory made on one machine can be mapped on another. schema_version changes when a field is removed or changes meaning. Adding a field does not change it: a reader ignores keys it does not know, so an older modelmap can map a newer inventory.

FileEntry(path, label, size_bytes, disk_bytes, charged=True, note='', used_by=list()) dataclass

One file of a record.

Parameters:

Name Type Description Default
path str

Real path of the file, with symlinks resolved.

required
label str

What the file is within its model: its path inside the model directory or snapshot, or the kind of an Ollama layer.

required
size_bytes int

Apparent size of the file itself.

required
disk_bytes int

Bytes allocated on disk.

required
charged bool

False when another record was charged for this file, so it adds nothing to this record's size.

True
note str

A remark such as not in the current revision.

''
used_by list[str]

Other records that use the same file. Deleting the file would break them too.

list()

ModelRecord(name, provider, format, path, size_bytes, disk_bytes, kind='model', family=None, quant=None, params=None, params_exact=True, mtime=None, files=1, file_list=list(), aliases=list(), shared_with=list(), issues=list()) dataclass

One model, dataset or cache entry found on disk.

Parameters:

Name Type Description Default
name str

Display name, for example mlx-community/Qwen3-8B-4bit.

required
provider str

Tool that owns the files: hf, ollama, omlx, lmstudio, llamacpp or generic.

required
format str

gguf, safetensors, mlx, pytorch and so on.

required
path str

Directory or file that holds the model.

required
size_bytes int

Apparent size, with shared files charged once.

required
disk_bytes int

Bytes allocated on disk, with shared files charged once.

required
kind str

model, auxiliary (a file that cannot run alone, such as a multimodal projector), dataset, cache or unattributed.

'model'
family str | None

Model family guessed from the name, such as qwen.

None
quant str | None

Quantization label, such as Q4_K_M or 4bit.

None
params int | None

Parameter count, or None when unknown.

None
params_exact bool

False when params is an estimate.

True
mtime float | None

Newest modification time among the files, as a POSIX time.

None
files int

Number of files.

1
file_list list[FileEntry]

The files themselves, in the order they were found.

list()
aliases list[str]

Other names for the same files, such as further Ollama tags that point at the same weights.

list()
shared_with list[str]

Names of records that share a file with this one.

list()
issues list[str]

Problems with this entry, such as a truncated header.

list()

Scan(records=list(), roots=list(), warnings=list(), elapsed_s=0.0, hostname=None, tool_version='', schema_version=SCHEMA_VERSION) dataclass

The result of one scan.

Parameters:

Name Type Description Default
records list[ModelRecord]

Everything found.

list()
roots list[ScanRoot]

Directories visited.

list()
warnings list[ScanWarning]

Paths that could not be read.

list()
elapsed_s float

Wall-clock scan time in seconds.

0.0
hostname str | None

Machine name, or None when redacted.

None
tool_version str

Version of modelmap that made the scan.

''
schema_version int

Version of this JSON layout.

SCHEMA_VERSION

disk_bytes property

Total allocated size of every record.

size_bytes property

Total apparent size of every record.

from_dict(data) classmethod

Rebuild a scan from :meth:to_dict output.

Parameters:

Name Type Description Default
data dict[str, Any]

Parsed JSON object.

required

Raises:

Type Description
ValueError

If the schema version is not the one this version of modelmap reads.

Source code in src/modelmap/records.py
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@classmethod
def from_dict(cls, data: dict[str, Any]) -> Scan:
    """Rebuild a scan from :meth:`to_dict` output.

    :param data: Parsed JSON object.
    :raises ValueError: If the schema version is not the one this
        version of modelmap reads.
    """
    version = data.get("schema_version")
    if version != SCHEMA_VERSION:
        raise ValueError(
            f"inventory has schema version {version!r}; "
            f"this modelmap reads version {SCHEMA_VERSION}"
        )
    scan = _load(cls, data)
    scan.records = [_load(ModelRecord, r) for r in data.get("records", [])]
    for record in scan.records:
        record.file_list = [_load(FileEntry, f) for f in record.file_list]
    scan.roots = [_load(ScanRoot, r) for r in data.get("roots", [])]
    scan.warnings = [_load(ScanWarning, w) for w in data.get("warnings", [])]
    return scan

ScanRoot(provider, path, resolved, source, exists=True) dataclass

A directory the scan visited.

Parameters:

Name Type Description Default
provider str

Provider the root belongs to, or user for a path given on the command line.

required
path str

The path as configured, before symlinks are resolved.

required
resolved str

The real path that was walked.

required
source str

What produced the path: an environment variable name, default, or argument.

required
exists bool

False when the path is absent.

True

ScanWarning(path, message) dataclass

Something the scan could not read or understand.

Parameters:

Name Type Description Default
path str

Where it happened.

required
message str

What went wrong.

required