nemo_curator.stages.interleaved.utils.materialization
nemo_curator.stages.interleaved.utils.materialization
Module Contents
Classes
Functions
Data
API
Bases: NamedTuple
Resolve filesystem paths and build per-filesystem deduplicated range indices.
Returns a list of (fs, unique_ranges) pairs — one entry per distinct
filesystem. unique_ranges maps (fs_path, offset, size) to the rows
that need that byte range. Returns an empty list if no valid paths exist.
Paths are grouped by filesystem instance (fsspec caches instances per
protocol and storage options), so cat_ranges is called once per
connection pool. Batches that span multiple storage backends (e.g.
local + S3) are handled correctly — each backend gets its own call.
Partition pending image rows into three I/O strategy groups.
- tar_extract: has member name but no byte_offset (must open tar and extractfile)
- range_read: has member + byte_offset + byte_size (can use fs.cat_ranges)
- direct_read: no member (path is the file itself)
- missing: path is None/NaN
Extract a single frame from a multi-frame TIFF, returning it as a single-frame TIFF.
Returns the raw bytes unchanged if the data is not a TIFF.
Read each direct file once, share bytes across all rows referencing it.
Batch byte-range reads grouped by filesystem, calling cat_ranges once per backend.
Deduplicates identical (path, offset, size) tuples globally so the same byte range is only fetched once even if referenced by multiple rows. Correctly handles batches that span multiple storage backends (e.g. local files mixed with remote files) by dispatching each group to its own fs.
Open each tar once and extract all needed members sequentially.
Distribute deduplicated range-read results, extracting TIFF frames as needed.
Return a task with image-row binary content materialized from source_ref.
Dispatches to three I/O strategies based on source_ref contents:
- range_read: byte_offset + byte_size present -> batched fs.cat_ranges()
- tar_extract: member present, no byte range -> open tar + extractfile
- direct_read: no member -> read file directly