vcti-fileloader
Plugin-based file loader framework that attaches locked subtrees into a LockableTree
Overview
Applications that work with simulation and CAE data load many file
formats, and each file's content is hierarchical — groups, datasets,
attributes. vcti-fileloader defines the protocol every loader plugin
implements: populate(handle, tree, parent) builds the file's content
as a new subtree under parent in a tree the application owns, and
locks it before returning, so several files combine into one browsable
tree with no merge step. Loaders pass the file's native attributes
through verbatim into a read-only side of each node payload
(file_attributes); a separate mutable side (enricher_attributes)
is left for the caller's post-load enrichment. The framework codes
against the LockableTree protocol from
vcti-tree, so the
caller picks the backing.
Install as vcti-fileloader; import from vcti.fileloader.core.
vcti.fileloader is a namespace package: loader plugins ship as their
own distributions beside core. The package is fully typed
(py.typed) and passes mypy --strict.
┌─────────────────────────────────────────────────────┐
│ Application Code │
│ (owns LockableTree, uses Loader protocol) │
└──────────────┬──────────────────────┬───────────────┘
│ │
┌───────▼───────┐ ┌───────▼───────┐
│ HDF5 Loader │ │ JSON Loader │ ...
│ (plugin pkg) │ │ (plugin pkg) │
└───────────────┘ └───────────────┘
attach subtrees into the tree
Installation
pip install "vcti-fileloader>=6.0.0"
dependencies = [
"vcti-fileloader>=6.0.0",
]
Quick Start
Register a plugin's loader at startup, then load a file into a tree
you own. hdf5_loader stands for a loader object from a plugin
package.
from pathlib import Path
from vcti.tree.core import DictTree, DictTreeHandle, descendants
from vcti.fileloader.core import (
DataNode,
LoaderDescriptor,
LoaderRegistry,
prepare_loader,
)
# At startup
registry = LoaderRegistry()
registry.register(LoaderDescriptor(
id="hdf5-h5py-loader",
name="HDF5 Loader (h5py)",
loader=hdf5_loader,
attributes={"supported_formats": ["hdf5-file"]},
))
# At runtime: validate and set up once; raises ValidationError / SetupError
loader = registry.get("hdf5-h5py-loader").loader
prepare_loader(loader)
# The application owns the tree
tree: DictTree[DataNode] = DictTree(DataNode())
handle = loader.load(Path("simulation.h5"))
try:
subtree_root: DictTreeHandle = loader.populate(handle, tree, tree.root_handle)
# The subtree is now structure-locked and payload-locked.
for h in descendants(tree, subtree_root):
node = tree.payload(h)
print(node.name, dict(node.attributes))
finally:
loader.unload(handle)
With a before_lock hook
The hook runs after the file's content is attached and before the locks fire. Use it to stamp attributes, compute derived values, or refuse the file by raising — a raise rolls the whole subtree back.
def stamp_source(tree, root):
for h in descendants(tree, root, include_self=True):
payload = tree.payload(h)
if payload is not None:
payload.enricher_attributes["file_path"] = "simulation.h5"
handle = loader.load(Path("simulation.h5"))
try:
root = loader.populate(handle, tree, tree.root_handle, before_lock=stamp_source)
finally:
loader.unload(handle)
print(tree.payload(root).attributes["file_path"])
The hook is any callable (tree, root) -> None. A rule-driven
enrichment library plugs in the same way; hand it the payloads
(tree.payload(h)), not the handles.
Key API
| Name | Role |
|---|---|
Loader |
Protocol every plugin implements: can_load, load, populate, unload, plus optional validator / setup. Structural — no base class. |
SubtreeBuilder |
Transactional helper for implementing populate: scoped writes, before_commit hook, lock on success, rollback on failure. |
DataNode |
Payload: data, name, read-only file_attributes, mutable enricher_attributes, and the merged attributes view (enricher first). |
LazyDataNode |
DataNode whose data loads on demand; shape and dtype are known before loading. |
materialise_subtree |
Load every LazyDataNode in a subtree, so the file can be closed. |
LoaderDescriptor / LoaderRegistry |
Register loaders with filterable metadata; look them up by id or attributes. |
LoaderValidator / LoaderSetup |
Optional protocols for checking and configuring a loader's runtime dependencies: return True, or raise ValidationError / SetupError with a diagnostic. |
prepare_loader |
Run a loader's validator and setup. Any failure of either step — a raised exception or a bare False — surfaces as ValidationError / SetupError respectively. Existing domain exceptions propagate unchanged; unexpected exceptions are preserved on __cause__. |
Lifecycle
- Prepare —
prepare_loader(loader)once, before the firstload(). - Check —
can_load(path)beforeload(). - Load —
load(path)opens the file and returns an opaque handle. - Populate —
populate(handle, tree, parent, before_lock=...)grafts the subtree underparent, runs the hook, locks, and returns the subtree root. On failure the partial subtree is removed. If that removal fails too — typically becauseparentwas structure-locked whilepopulateran — the error carries a note naming the subtree and the state it was found in. - Unload —
unload(handle)releases resources; idempotent. Lazy nodes may hold the handle: callmaterialise_subtree(tree, root)first if the tree must stay usable after unload.
Error Handling
All exceptions inherit from LoaderError:
| Exception | Raised when |
|---|---|
LoadError |
A file cannot be opened or parsed |
LazyLoadError |
A LazyDataNode cannot produce its data (a LoadError, and a RuntimeError) |
UnsupportedFormatError |
A loader does not recognize the file format |
UnloadError |
Resource cleanup failed |
ValidationError |
A loader's validator found unmet requirements (raised by it, or by prepare_loader on False) |
SetupError |
A loader's setup could not configure the environment (raised by it, or by prepare_loader on False) |
TreeAttachmentError |
populate() cannot attach: parent is missing, deleted, or structure-locked |
TreeAttachmentError wraps the tree's own exception, which stays on
__cause__.
Dependencies
- numpy (>=1.24) — array-aware
DataNodeequality and display - vcti-plugin-catalog (>=2.0.0) — descriptor and registry base classes
- vcti-tree (>=3.0.0) —
LockableTreeprotocol, walks, and tree exceptions
Versioning
This package follows Semantic Versioning.
Breaking changes to the Loader protocol, SubtreeBuilder semantics or
the DataNode shape only occur in major versions. Loader plugins should
pin a compatible major version, e.g. vcti-fileloader>=6.0,<7.
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| Implement a loader, wire hooks, handle errors and lazy data | docs/patterns.md |
| Understand the architecture, attribute model and locking model | docs/design.md |
Metadata
Release files for vcti-fileloader 6.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vcti_fileloader-6.0.0.tar.gz | 41.2 kB | With provenance | Details for vcti_fileloader-6.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vcti_fileloader-6.0.0-py3-none-any.whl | Python 3 | none | any | Details for vcti_fileloader-6.0.0-py3-none-any.whl |
Total release size: 64.9 kB
Release files / vcti_fileloader-6.0.0.tar.gz
| Download URL | vcti_fileloader-6.0.0.tar.gz |
|---|---|
| Size | 41.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7802947ec43f24d8059796fbdfc8668b71d92b9e0f2f1a0e7ef748ff1e3e5f3b
|
|
BLAKE2b-256 checksum How to use checksums |
7a3dd4a43200edf63920c738931b5051b18bf11867808dec55fc29ba4b95299d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / vcti_fileloader-6.0.0-py3-none-any.whl
| Download URL | vcti_fileloader-6.0.0-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c78578d21bb9ef95f9903b241767f4dd0f92a7d5819e2277c6315e8456d22a3e
|
|
BLAKE2b-256 checksum How to use checksums |
8deaf8f773ab1602dd67ce40b213a3239a53d5c081c1c98e921713c99b77060a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for vcti-fileloader 6.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for vcti_fileloader-6.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.