iatro-base-iac
IatroCache (.iac) — a lightweight, high-performance binary container format for offline caching of multimodal medical datasets (image tiles, feature vectors, clinical text, expert tokens, etc.).
This package provides the core container format and readers/writers for .iac files. It is designed for high-concurrency training pipelines, with explicit owned-byte and memory-mapped (mmap) zero-copy read APIs.
Installation
pip install iatro-base-iac
Python API
from iatro.iac import Codec, PackReader, build_pack
Format Layout
[ fixed header ] 65536 bytes — magic "IATROC", JSON header (codec, payload_type, offsets, ...)
[ slide table ] Arrow IPC — slide_idx / slide_id / patient_id
[ index table ] Arrow IPC — caller-defined columns + offset / length / crc32
[ data segment ] raw bytes — concatenated payloads, indexed by the index table
Key Technical Features
- Explicit Boundaries & Integrity: Each record carries
offset/length/crc32. Payload boundaries are explicit, eliminating the need to scan for framing markers. This works seamlessly for codecs without self-delimiting frames (e.g. raw Brotli). - High Performance:
PackReader.read_payload_views()exposes zero-copy, lock-free mmap views for batch decoding, whileread_payload()andread_payloads()always return ownedbytes. - Metadata Flexibility:
payload_typeandcodecare free-form header fields; the low-level container does not interpret the payload bytes directly.
Quick Start (Core API)
Below is an example of writing raw bytes to an .iac pack and reading them back:
import pyarrow as pa
from iatro.iac import build_pack, PackReader
# 1. Define metadata tables
slide_table = pa.table({
"slide_idx": pa.array([0], pa.uint8()),
"slide_id": ["s0"],
"patient_id": ["p0"]
})
# Offset, length, and crc32 columns are populated automatically
index_table = pa.table({
"item_id": ["item_a", "item_b"]
})
# 2. Build the cache file
build_pack(
output_path="out.iac",
header_json={"payload_type": "raw_bytes", "codec": Codec.NONE},
slide_table=slide_table,
index_table=index_table,
payloads=[b"first_payload_data", b"second_payload_data"]
)
# 3. Read payloads concurrently
reader = PackReader("out.iac")
print(reader.read_payload(1)) # Output: b"second_payload_data"
# Stable owned-data API: always list[bytes]
owned = reader.read_payloads([0, 1])
# Explicit zero-copy API: always list[memoryview], or raises if mmap is unavailable
views = reader.read_payload_views([0, 1])
reader.close()
For large-scale or streaming datasets, refer to build_pack_streaming, build_pack_data_segment, and build_pack_data_segment_from_file.
Pack-level codecs use one public interface. Native byte codecs are selected
without a Python implementation wrapper, while user codecs may inherit
Codec and register a reconstruction factory:
codec = Codec.create(Codec.ZSTD, level=3)
Reusable concrete schemas are distributed separately in
iatro-iac-adapters. The adapter package depends on this core, so one command
installs both:
pip install iatro-iac-adapters
Contributing & License
This project is licensed under the MIT License. Codec and Pack contributions are welcome.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iatro_base_iac-0.1.0.tar.gz.
File metadata
- Download URL: iatro_base_iac-0.1.0.tar.gz
- Upload date:
- Size: 56.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d584fb94313775b241331e434ce000289078d6ff2ffb44b505141bacea292146
|
|
| MD5 |
1a43fecc624789833d99d84da86dc60c
|
|
| BLAKE2b-256 |
d1a391d30323faad383a114d667bcac6627da0001f254e18a8d6dde06e8009d7
|
File details
Details for the file iatro_base_iac-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: iatro_base_iac-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8de954a1f50075e52ac229fc69c0f0ea8c85ca7e4c3655791f41649adb87338c
|
|
| MD5 |
df07d485fd7bfed851c967723150342f
|
|
| BLAKE2b-256 |
8eb788f7da5e8b0f3a55792a37263ea2badd8491e37e060c251d3a97e982b9af
|