MCPcopy
hub / github.com/MinishLab/semble / _metadata_matches

Function _metadata_matches

src/semble/cache.py:96–107  ·  view source on GitHub ↗

Return True if the stored metadata is compatible with the requested parameters.

(metadata: dict, model_path: str, content: Sequence[ContentType])

Source from the content-addressed store, hash-verified

94
95
96def _metadata_matches(metadata: dict, model_path: str, content: Sequence[ContentType]) -> bool:
97 """Return True if the stored metadata is compatible with the requested parameters."""
98 from semble.chunking.chunking import _DESIRED_CHUNK_LENGTH_CHARS # avoid circular import at module level
99
100 try:
101 content_type = tuple(ContentType(s) for s in metadata["content_type"])
102 # chunk_size is absent in indexes built before this field was added; treat None as mismatch
103 # so old caches are transparently rebuilt with the current chunk size.
104 chunk_size_ok = metadata.get("chunk_size") == _DESIRED_CHUNK_LENGTH_CHARS
105 return metadata["model_path"] == model_path and set(content_type) == set(content) and chunk_size_ok
106 except (KeyError, ValueError):
107 return False
108
109
110def get_validated_cache(path: str, model_path: str | None, content: Sequence[ContentType]) -> Path | None:

Callers 1

get_validated_cacheFunction · 0.85

Calls 2

ContentTypeClass · 0.90
getMethod · 0.80

Tested by

no test coverage detected