Metadata-Version: 2.4
Name: hugpy-resources
Version: 0.1.18
Summary: Shared generic utilities, file inspection and model resource evidence contracts
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: abstract_essentials>=0.0.0.31
Requires-Dist: abstract_search>=0.1.9
Provides-Extra: inspection
Requires-Dist: sentencepiece>=0.2; extra == "inspection"
Requires-Dist: protobuf>=4; extra == "inspection"
Provides-Extra: yaml
Requires-Dist: PyYAML; extra == "yaml"

# hugpy-resources

Hugpy Resources is the shared function library used by Discovery, Wrapper, Core and other Hugpy packages. It supplies the vocabulary and calculations that let a model record, a memory estimate and a placement decision use the same units and definitions.

## Installation

Install the base distribution for the shared functions. The `inspection` extra adds tokenizer inspection dependencies. The `yaml` extra adds YAML support.

```sh
python -m pip install hugpy-resources
```

## Quick start

Calculate the stored payload of a dense tensor from its shape and element width.

```python
from hugpy_resources.imports import tensor_bytes

payload = tensor_bytes((32, 128), 2)
print(payload)  # 8192 bytes
```

## Working with resource evidence

| Task | What the library supplies |
| --- | --- |
| Inspect a model directory | Readers for GGUF and safetensors headers, model configuration, tensor shapes and stored types |
| Estimate a placement | Tensor and KV-cache sizing, device budgets, layer allocation and resource bounds |
| Read or publish state | Filesystem, hashing, SQLite, settings and HTTP functions shared by the services |
| Interpret a record | Typed terms, units, domain settings and human-readable definitions |

A tensor payload accounts for stored elements. A runtime peak also depends on context, representation, allocator overhead and backend workspaces. Keep missing bounds explicit when deciding whether a model fits.

## Integration

Import individual names from `hugpy_resources.imports`. In a Hugpy service, expose the names once in the service’s `imports/module_imports.py`. Consumers can then use the same implementation through their package’s import boundary. Source contributors can find the term definitions under `src/hugpy_resources/imports/TERMS/`.

## Shared imports

Service packages expose the functions they use through their own imports module. This keeps model inspection, hashing and placement calculations consistent across producers and consumers. For example, Discovery records evidence from model files, Wrapper uses those facts when selecting a placement, and Core reads the worker’s published results. Callers that need to distinguish a missing measurement from a measured zero should preserve that distinction throughout.
