Skip to main content

Python binding (pyo3 / maturin)

A thin pyo3 wrapper over the single nirs4all-io Rust core (the facade crate) — all RESOLVE → INFER → CONFIGURE → MATERIALIZE logic lives in Rust; Python only adapts the results.

Layout (mixed maturin)

  • Native extension nirs4all_io._native (the pyo3 module, built from src/lib.rs).
  • Python package nirs4all_io (under python/) that wraps _native and adds the lazy SpectroDataset adapter (_adapter.py).

numpy and pandas are wheel runtime dependencies — they back the full-array SpectroDataset reconstruction and are not nirs4all.

Build & install

maturin develop          # build + install into the active venv (dev)
maturin build            # build an abi3 wheel (abi3-py311)
pip install <wheel>      # install the built wheel

Requires Python ≥ 3.11. See PACKAGING.md for the abi3 wheel / nirs4all-formats reuse details.

API

All functions are re-exported from nirs4all_io.

Function Signature Returns
infer infer(input, conventions=None) a DatasetPlan (data input only)
to_spec to_spec(input, conventions=None, name=None) a DatasetSpec
validate validate(spec) None; raises ValueError if invalid
load load(input, *, target="assembled", conventions=None, name=None, base_dir=None, spectro_dataset_cls=None) summary dict, DatasetPackage, or a SpectroDataset
to_dataset_package to_dataset_package(input, *, conventions=None, base_dir=None, name=None) a target-agnostic DatasetPackage
describe_dataset_package describe_dataset_package(input, *, conventions=None, base_dir=None, name=None, canonical=False) package summary dict or canonical JSON
to_spectrodataset to_spectrodataset(full, *, spectro_dataset_cls=None) a SpectroDataset

Inputs (input) accept a str path, a pathlib.Path, a sequence of either (file list), or a dict (a spec). validate additionally accepts a JSON string.

Typed results. infer returns a DatasetPlan and to_spec a DatasetSpec. Both subclass dict — they stay subscriptable, JSON-serializable, and valid inputs to validate / load — and add a readable repr plus convenience accessors:

  • DatasetSpec: .name, .schema_version, .sources.
  • DatasetPlan: .overall_score, .resolved_spec (a DatasetSpec), .recommendations, .warnings, and .decisions() (the scored structure/signal_type/task_type decisions, keyed by kind).
>>> plan = nio.infer("/data/run")
>>> plan
DatasetPlan(overall_score=0.883, structure='x_y_separate'(0.85), ...)
>>> plan.decisions().keys()
dict_keys(['structure', 'signal_type', 'task_type'])
>>> plan.resolved_spec
DatasetSpec(name='data', schema_version=1, sources=[data:mixed])

load targets:

  • target="assembled" → the rounded structural summary dict (no nirs4all).
  • target="dataset_package" / target="package" → a target-agnostic DatasetPackage with payload manifest hashes and an assembled view.
  • target="spectrodataset" → a real nirs4all SpectroDataset, built via a lazy nirs4all import inside the adapter. This is the only nirs4all touch-point; import nirs4all_io never imports nirs4all (enforced by tests/test_import_boundary.py). Inject spectro_dataset_cls= to drive the builder with a double (testing without nirs4all).

Usage

from pathlib import Path
import nirs4all_io as nio

plan = nio.infer(Path("/data/run"))            # DatasetPlan (typed dict)
spec = nio.to_spec("/data/run")                # DatasetSpec (typed dict)
nio.validate(spec)                             # raises ValueError if invalid

print(spec.schema_version, len(spec.sources))  # convenience accessors
print(plan.decisions())                        # scored inference decisions

summary = nio.load("/data/run")                # target="assembled" (default)
package = nio.to_dataset_package("/data/run")  # target-agnostic package
ds = nio.load("/data/run", target="spectrodataset")   # nirs4all SpectroDataset

Test

pytest bindings/python/tests

Download files

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

Source Distribution

nirs4all_io-0.1.18.tar.gz (380.0 kB view details)

Uploaded Source

Built Distributions

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

nirs4all_io-0.1.18-cp311-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

nirs4all_io-0.1.18-cp311-abi3-manylinux_2_34_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

nirs4all_io-0.1.18-cp311-abi3-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file nirs4all_io-0.1.18.tar.gz.

File metadata

  • Download URL: nirs4all_io-0.1.18.tar.gz
  • Upload date:
  • Size: 380.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nirs4all_io-0.1.18.tar.gz
Algorithm Hash digest
SHA256 d27fe7db6f405535470dcedc5a7975c2ff3c794ff740faacb8a9cf34756f780c
MD5 8f428332b28006279c2482ff16acb25e
BLAKE2b-256 fc41815f59f990cb770a33c02afac5158568a616c3e73afa30230a9caedd6a8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.18.tar.gz:

Publisher: release.yml on GBeurier/nirs4all-io

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

File details

Details for the file nirs4all_io-0.1.18-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.18-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 587bdbf470e7063ec5f45651d2f10b20002e242f6b6c510d68b414e92b4c1cf0
MD5 e94117133e2bf734ff329ff38baacb1a
BLAKE2b-256 61f019612d3f4dff3c2217583724d4b351674afe81113fe449b5db09a08af6dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.18-cp311-abi3-win_amd64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

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

File details

Details for the file nirs4all_io-0.1.18-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.18-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b3ca1303998646dcc93f4fe865c6b74878d3a035b0575defe2dc238ce2e28865
MD5 70a821e5b861e29be76ee36c43b71f75
BLAKE2b-256 6c729d07fb21b49f4ef7e4fa745c4f58ea6acf5e4564e2cc05b34398571d4f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.18-cp311-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

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

File details

Details for the file nirs4all_io-0.1.18-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.18-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca813a587810103d8b28afd4fe82d81c8aeea96d881f0c6ebdcce0d939c06984
MD5 9aa55b46b4acb8a78b970c5349ebe56a
BLAKE2b-256 fdfa8906ad1cd5ea63e01176e5f3ba8c9b3dea7280266a854fc8371b89a232e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.18-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

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

0.1.18 This release

4 files

0.1.14

4 files

0.1.13

4 files

0.1.12

4 files

0.1.11

4 files

0.1.10

4 files

0.1.9

4 files

0.1.7

4 files

0.1.6

4 files

0.1.5

4 files

0.1.4

4 files

0.1.3

4 files

0.1.2

4 files

0.1.1

4 files

0.1.0

4 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page