Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

tensogram set

Modifies metadata keys in messages and writes the result to a new file. Matching messages are decoded, their metadata is updated, and they are re-encoded with the original payload bytes and pipeline settings.

Usage

tensogram set [OPTIONS] -s <SET_VALUES> <INPUT> <OUTPUT>

Options

OptionDescription
-s <SET_VALUES>Key=value pairs to set (comma-separated)
-w <WHERE_CLAUSE>Only modify messages matching this filter (e.g. mars.param=2t)
-h, --helpPrint help

Examples

# Change mars.date to 20260402 in all messages
tensogram set input.tgm output.tgm mars.date=20260402

# Set multiple keys at once
tensogram set input.tgm output.tgm mars.date=20260402,mars.step=12

# Only modify temperature fields
tensogram set input.tgm output.tgm mars.class=rd -w "mars.param=2t"

Key=Value Syntax

Multiple mutations can be specified as a comma-separated list:

tensogram set in.tgm out.tgm key1=val1,key2=val2,key3=val3

Keys use dot-notation: mars.param sets the param field inside the mars namespace. A top-level key like experiment sets a top-level metadata field.

Object-level metadata can be updated with objects.<index>.<path>:

# Add object-specific metadata to the first object
tensogram set input.tgm output.tgm objects.0.processing.version=2

Structural/Integrity Keys

The following keys cannot be modified because they describe the physical structure of the payload. Changing them would make the metadata inconsistent with the actual bytes on disk:

KeyReason
shapeTensor dimensions
stridesMemory layout
dtypeElement type
ndimNumber of dimensions
typeObject type
encodingEncoding algorithm
filterFilter algorithm
compressionCompression algorithm
hashPayload integrity hash
szip_rsiSzip compression block parameter
szip_block_sizeSzip compression block parameter
szip_flagsSzip compression flags
szip_block_offsetsSzip block seek table
sp_reference_valueSimple packing quantization parameter
sp_binary_scale_factorSimple packing quantization parameter
sp_decimal_scale_factorSimple packing quantization parameter
sp_bits_per_valueSimple packing quantization parameter
shuffle_element_sizeShuffle filter parameter

Attempting to modify any of these returns an error before any output is written.

Pass-Through for Non-Matching Messages

Messages that do not match the -w filter are copied verbatim to the output file. Their bytes are not re-encoded or re-hashed.

Note: Messages that are modified are re-encoded after the metadata mutation. Because the decoded payload bytes are unchanged, set preserves the original payload hash instead of recomputing it.

Workflow

flowchart TD
    A[Read message] --> B{Matches -w?}
    B -- No --> C[Write raw bytes to output]
    B -- Yes --> D[Decode metadata]
    D --> E[Apply mutations]
    E --> F[Re-encode message\npreserve payload hash]
    F --> G[Write to output]
    C --> H[Next message]
    G --> H