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

Metadata

Release files for nirs4all-io 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nirs4all-io 0.2.5
File Size Uploaded
nirs4all_io-0.2.5.tar.gz 426.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for nirs4all-io 0.2.5
File Interpreter ABI Platform
nirs4all_io-0.2.5-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
nirs4all_io-0.2.5-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details
nirs4all_io-0.2.5-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 10.6 MB

Release files / nirs4all_io-0.2.5.tar.gz

Download URL nirs4all_io-0.2.5.tar.gz
Size 426.8 kB
Tags Source
SHA-256 checksum
How to use checksums
04f1351e6b62cb89941e2d3639bba9eab49fdadd964b25d3160fde9806b1b189
BLAKE2b-256 checksum
How to use checksums
8899758e840944da2d04b026b1f64470fb4483c656214469d44e1bb2a8c508f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / nirs4all_io-0.2.5-cp311-abi3-win_amd64.whl

Download URL nirs4all_io-0.2.5-cp311-abi3-win_amd64.whl
Size 3.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
432d2e416f8fe8eef3b45dac5445a3e5763a90e59f78d4ead2adee1d4e64d8cf
BLAKE2b-256 checksum
How to use checksums
1d546e34360bfb66bf3e1d6794de803b993f78bd2b6730ddae9b04fe763a994d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / nirs4all_io-0.2.5-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL nirs4all_io-0.2.5-cp311-abi3-manylinux_2_34_x86_64.whl
Size 3.9 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
7f3c6ac627eb63c159fb20115b9843b3779ac68bcf1b24bade04e7a11b2dc363
BLAKE2b-256 checksum
How to use checksums
a52ac3dfd23d8716934c792e43a555cdccb6ebf316a24400539880944b0c81eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / nirs4all_io-0.2.5-cp311-abi3-macosx_11_0_arm64.whl

Download URL nirs4all_io-0.2.5-cp311-abi3-macosx_11_0_arm64.whl
Size 3.2 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fb20abccf1cb58e7a3e165e82ab054026a73e95e7b8e69d5d1cd67d6b2ebdfea
BLAKE2b-256 checksum
How to use checksums
fec2e29f3bb78eb5981ad2bb7e82e056dab067d7f8f9d6aa82820903b6d2bf9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.10

4 release files

0.2.9

4 release files

0.2.6

4 release files

This release

0.2.5 This release

4 release files

0.2.4

4 release files

0.2.2

4 release files

0.2.0

4 release files

0.1.9

4 release files

0.1.7

4 release files

0.1.6

4 release files

0.1.5

4 release files

0.1.4

4 release files

0.1.3

4 release files

0.1.2

4 release files

0.1.1

4 release files

0.1.0

4 release 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