Format-agnostic exporters for vcti trees: an Exporter protocol and registry, with per-format writers as plugins.
Project description
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.treeexporter import build_registry, get_exporter
from vcti.treeexporter_hdf5 import get_exporter_descriptor as hdf5_descriptor
from vcti.treeexporter_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.treeexporter 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.treeexporter 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
- vcti-tree — the tree protocols the exporter reads.
- vcti-datanode — the node payload type.
- vcti-plugin-catalog — the
Descriptor/Registrycatalog.
(No heavy/runtime format dependencies live here — those belong to the per-format plugin packages.)
Project details
Release history Release notifications | RSS feed
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 vcti_tree_exporter-1.0.0.tar.gz.
File metadata
- Download URL: vcti_tree_exporter-1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8553c72693e16bbc7c23780304b72544232cd4399d5f437d6398c7f3dd3a3d91
|
|
| MD5 |
7d846262d29f8bcc8cd24a8873c05cde
|
|
| BLAKE2b-256 |
061e47ecfee99c987a8d49d3a8338fc1d34807aa27d3499cc96fc05877857eb6
|
Provenance
The following attestation bundles were made for vcti_tree_exporter-1.0.0.tar.gz:
Publisher:
release.yml on vcollab/vcti-python-tree-exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_tree_exporter-1.0.0.tar.gz -
Subject digest:
8553c72693e16bbc7c23780304b72544232cd4399d5f437d6398c7f3dd3a3d91 - Sigstore transparency entry: 1981252727
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-tree-exporter@b813104244846019bfc3f9cd56d38716f73ca3a8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b813104244846019bfc3f9cd56d38716f73ca3a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vcti_tree_exporter-1.0.0-py3-none-any.whl.
File metadata
- Download URL: vcti_tree_exporter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2837a9145f05a5e3c0193f67b744e35e64790b7138445ddb5aa059a17f27a21
|
|
| MD5 |
38935fed9336e4e1b454db6ebf39c2cd
|
|
| BLAKE2b-256 |
949a787db6ac434b1bc1a3eef3fecf08a21264bc8d2d942d7ad57c289e02f231
|
Provenance
The following attestation bundles were made for vcti_tree_exporter-1.0.0-py3-none-any.whl:
Publisher:
release.yml on vcollab/vcti-python-tree-exporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_tree_exporter-1.0.0-py3-none-any.whl -
Subject digest:
e2837a9145f05a5e3c0193f67b744e35e64790b7138445ddb5aa059a17f27a21 - Sigstore transparency entry: 1981253251
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-tree-exporter@b813104244846019bfc3f9cd56d38716f73ca3a8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b813104244846019bfc3f9cd56d38716f73ca3a8 -
Trigger Event:
push
-
Statement type: