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 |
''
|
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 |
required |
provider
|
str
|
Tool that owns the files: |
required |
format
|
str
|
|
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'
|
family
|
str | None
|
Model family guessed from the name, such as |
None
|
quant
|
str | None
|
Quantization label, such as |
None
|
params
|
int | None
|
Parameter count, or None when unknown. |
None
|
params_exact
|
bool
|
False when |
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 | |
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 |
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,
|
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 |