Skip to main content

Data Node

The node value type for a hierarchical data model — a single DataNode that composes optional array data, structural identity, and layered metadata.

Overview

vcti-datanode provides DataNode, the payload for a tree whose nodes carry heavy array data, metadata, both, or neither. A node composes three independent, optional parts rather than splitting into a subclass per combination:

  • a DataSource — how the node's array is obtained and how long it stays resident. EagerDataSource wraps an array already in hand; LazyDataSource produces one on demand via a callable (read a file, compute a derived array, query a service) and can be released and re-loaded. A node with no data has no data source.
  • intrinsic attributes — the node's structural identity (name, shape, dtype, …), kept in their own namespace so they never collide with free-form metadata.
  • metadata in two provenance layers — source_attributes (immutable, as received) and enriched_attributes (mutable, added later), merged for reading as attributes.

It is built for CAE-style models read from a file (or built in memory), transformed, and exported — but depends on nothing beyond numpy and works anywhere a data-plus-metadata node is useful. See docs/design.md for the concepts and rationale.

Installation

pip install vcti-datanode

In requirements.txt

vcti-datanode>=2.0.0

In pyproject.toml dependencies

dependencies = [
    "vcti-datanode>=2.0.0",
]

Quick Start

import numpy as np
from vcti.datanode import DataNode, EagerDataSource, LazyDataSource

# A metadata-only node (no data) — e.g. a grouping node.
group = DataNode(name="results", enriched_attributes={"analysis": "modal"})

# An eager node: the array is already in hand.
stress = DataNode(
    name="stress",
    data_source=EagerDataSource(np.array([1.0, 2.0, 3.0])),
    source_attributes={"units": "MPa"},
)
stress.shape            # (3,) — a derived intrinsic, read without touching data
stress.attributes["units"]   # 'MPa'

# A lazy node: the array is fetched on demand and can be released.
disp = DataNode(
    name="displacement",
    data_source=LazyDataSource(lambda: np.load("disp.npy"), shape=(2, 3), dtype="float64"),
    source_attributes={"units": "mm"},
)
disp.is_loaded          # False — but disp.shape is already (2, 3)
arr = disp.load()       # loader runs once; cached thereafter
disp.unload()           # frees the array; metadata and intrinsics remain

Comparison is explicit (nodes compare by identity, not value):

from vcti.datanode import metadata_equal, data_equal, node_equal

metadata_equal(a, b)    # intrinsic + metadata; never loads data
data_equal(a, b)        # compares arrays, materialising if needed
node_equal(a, b)        # both

Run the example end to end to see the package working:

python examples/basic_usage.py

Documentation


Dependencies

  • numpy>=1.26 — array data, and structural facts (shape/dtype).

Download files

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

Source Distribution

vcti_datanode-2.0.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

vcti_datanode-2.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vcti_datanode-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a0216b7981388e8e9b0514e73f6f6deca00a521d081a6aa8f83467503750cff6
MD5 4c81052a44a717094c372dda728edb67
BLAKE2b-256 6ac3853d79ef258fdbebd71adf6df54333c6487806a839b08501590d4f8a2470

See more details on using hashes here.

Provenance

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

Publisher: release.yml on vcollab/vcti-python-datanode

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_datanode-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcti_datanode-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vcti_datanode-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b50150b47036dc3ca0c47419c8a067e093efcbabdab1280bcea5c827f576a05
MD5 e212e934506ba2eee474ed23f9100c5f
BLAKE2b-256 cbee1449f02c40379b2cdb09d9a1f4cdff7086d607fb109e8ef724471e14d964

See more details on using hashes here.

Provenance

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

Publisher: release.yml on vcollab/vcti-python-datanode

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.1

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