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.12.tar.gz (344.3 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.12-cp311-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

nirs4all_io-0.1.12-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.12-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.12.tar.gz.

File metadata

  • Download URL: nirs4all_io-0.1.12.tar.gz
  • Upload date:
  • Size: 344.3 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.12.tar.gz
Algorithm Hash digest
SHA256 b827f27561f6eacbb01873cdea72ac8b3a6466d493fda88824ffcd661a88e0ed
MD5 210eb7f426e401e8025fb0e7cba66756
BLAKE2b-256 041385eb527f6e765a8a01f9726917fb9cc2cf723d6103056f8e75df498f942d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.12.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.12-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.12-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 731c8eab828eeef80102f3e107fc6a842da7c79baa9647b2d874eef7457790a3
MD5 d7473a62e6a6151dbb135eebfe26999c
BLAKE2b-256 80804e06d64c15dca3af7a0c78e83099ddbb15c48e7700b86f934e477ece837a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.12-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.12-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.12-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bb7638879b5dfe1fb054680e4edea5619526f2e99ea3ac5cdce0ebbe5c248769
MD5 cfdc197e0370ea1fcca3c1fa5aab7677
BLAKE2b-256 6f855f5e64e19726d01260ec0c6975bf96d124bfb52fcb1527a137fdf724073f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.12-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.12-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.12-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd5161b2d5fb9c4a49bd7ab6a17c3c15f260f3e6d7902a82dc9f69b8b5fc0486
MD5 c67ce001b56717da2bcbbf6707c89e66
BLAKE2b-256 5287cb1dc3eb9a743dd6bf92a031a0a4346a0b6ec5bba6585782810cc822bda2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.12-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

0.1.18

4 files

0.1.14

4 files

0.1.13

4 files

This release

0.1.12 This release

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