upxo.meshing.gbconformant.pipeline.serialize module

Portable files for pipeline results: a JSON skeleton plus an npz of arrays.

Arrays, numbers, strings, lists, tuples, sets, dictionaries (any hashable key, including tuples), paths and the result dataclasses of this package are written without pickle, so the files can be read by other tools and are safe to open. A file records a format name and version; a reader refuses a version it does not know. Only dataclasses from upxo.meshing.gbconformant are rebuilt when reading.

exception upxo.meshing.gbconformant.pipeline.serialize.SerializeError[source]

Bases: TypeError

A value cannot be written in the portable form.

upxo.meshing.gbconformant.pipeline.serialize.encode(value, arrays=None, where='value')[source]

Return (skeleton, arrays): JSON-able structure and the arrays it refers to.

upxo.meshing.gbconformant.pipeline.serialize.decode(skeleton, arrays)[source]

Rebuild a value from encode() output (arrays maps names to arrays).

upxo.meshing.gbconformant.pipeline.serialize.safe_name(key)[source]

File-system safe stem for an artefact key.

upxo.meshing.gbconformant.pipeline.serialize.write_value(stem, value, where='value')[source]

Write value as <stem>.json (+ <stem>.npz when it holds arrays).

Returns {'json': name, 'npz': name or None}; raises SerializeError.

upxo.meshing.gbconformant.pipeline.serialize.read_value(stem)[source]

Read what write_value() wrote; refuses an unknown format or version.