Skip to main content

Tree Exporter

Format-agnostic exporters for vcti trees: an Exporter protocol and a plugin catalog, with per-format writers as plugins.

vcti-tree-exporter defines what an exporter is and how to catalogue and look one up. It implements no file format itself — concrete writers (HDF5, JSON, CSV, NumPy, …) live in separate plugin packages and are registered by the consumer. The thing being exported is any vcti-tree tree whose node payloads are vcti-datanode DataNodes (data + attributes), so one tree can be written to any registered format without the producer knowing about serialization.

Cataloguing and lookup are built on vcti-plugin-catalog (Descriptor + Registry).

Installation

pip install vcti-tree-exporter

The base package is intentionally small. Install a format plugin for each format you need:

pip install vcti-tree-exporter-hdf5    # single .h5 file
pip install vcti-tree-exporter-json    # single .json document
pip install vcti-tree-exporter-npz     # single .npz archive
pip install vcti-tree-exporter-csv     # directory tree of CSV tables

Core concepts

Piece Role
Exporter Structural protocol — a single export(tree, path, *, overwrite=False) method. Pure behavior; format name and extension are not on the exporter.
ExporterDescriptor A vcti-plugin-catalog Descriptor[Exporter]: the exporter is its instance; format, extension, and any other metadata are filterable attributes.
get_exporter_descriptor() Factory each plugin package provides, returning its ExporterDescriptor.
build_registry(descriptors) Build a plugin-catalog Registry from those descriptors.
get_exporter(registry, id) Resolve an exporter instance by descriptor id.

Quick Start

Register the descriptors your application uses, then resolve one and write a tree:

from pathlib import Path
from vcti.tree.exporter.core import build_registry, get_exporter
from vcti.tree.exporter.hdf5 import get_exporter_descriptor as hdf5_descriptor
from vcti.tree.exporter.json import get_exporter_descriptor as json_descriptor

registry = build_registry([hdf5_descriptor(), json_descriptor()])
get_exporter(registry, "hdf5").export(tree, Path("model.h5"), overwrite=True)

registry is an ordinary vcti.plugincatalog.Registry, so the general way to select an exporter is to filter by attributes, then use the matching id — the same pattern as the rest of the ecosystem:

from vcti.lookup import Rule
from vcti.tree.exporter.core import EXTENSION_ATTR

(desc,) = registry.lookup.filter([Rule(EXTENSION_ATTR, "==", ".h5")])
desc.exporter.export(tree, Path("model.h5"))

Exporter ids are a small, fixed, well-known set, so using get_exporter(registry, "hdf5") directly is also fine.

Writing a format plugin

A plugin's exporter only has to satisfy the protocol — one export method, no base class — and ship a get_exporter_descriptor() factory carrying its metadata:

from pathlib import Path
from vcti.tree.exporter.core import EXTENSION_ATTR, FORMAT_ATTR, ExporterDescriptor

class JsonExporter:
    def export(self, tree, path: Path, *, overwrite: bool = False) -> None:
        ...   # walk the tree (node.name, node.attributes, node.load()), write JSON

def get_exporter_descriptor() -> ExporterDescriptor:
    return ExporterDescriptor(
        id="json", name="JSON Exporter", exporter=JsonExporter(),
        attributes={FORMAT_ATTR: "json", EXTENSION_ATTR: ".json"},
    )

Ship it in its own package (with its own format dependencies, e.g. h5py for HDF5). The consuming application decides which descriptors to register — there is no implicit global discovery.

Dependencies

(No heavy/runtime format dependencies live here — those belong to the per-format plugin packages.)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_tree_exporter-2.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_tree_exporter-2.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file vcti_tree_exporter-2.0.0.tar.gz.

File metadata

  • Download URL: vcti_tree_exporter-2.0.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vcti_tree_exporter-2.0.0.tar.gz
Algorithm Hash digest
SHA256 27bc88eac7cc2f485ffd92eb00c74197ee8466efd8a26a6386012d84612221b9
MD5 57f70d1d4261719075ed3e9f1fabf0c3
BLAKE2b-256 5133b0135d2ab5bb23de03bc5d907ce220d14a9da053e8d36a368f5472080ca5

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_tree_exporter-2.0.0.tar.gz:

Publisher: release.yml on vcollab/vcti-python-tree-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_tree_exporter-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vcti_tree_exporter-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61f04498329fb6d48876160d3916de822cfaa0214fac28f2733462c44c7f2845
MD5 d8772c2ef1258e79275f6df73df73dd3
BLAKE2b-256 b44262f702f564c7bc42f8ee1e2a0e89f733ef1b93368d02685b8c1a8c3b1f98

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_tree_exporter-2.0.0-py3-none-any.whl:

Publisher: release.yml on vcollab/vcti-python-tree-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page