Skip to main content

STDF parser and writer

Project description

stdfast

This is a fork from stupidf, jlazear

stdfast is a library for parsing and writing of STDF files. The STDF structure can be used directly in rust, or alternatively sent out to Python. The library exposes several functions to read and write STDF file records from python. Additionally, there is a pydantic model for each record type to simplify the handling in python.

STDF is the Standard Test Data Format and is commonly used for high-volume test of semiconductors in Automated Test Equipment (ATE) systems.

The purpose of the library is to quickly and efficiently parse and write STDF files (which are a fairly unfriendly binary linked list-based format).

Examples

Python

Also contains Python bindings to this functionality, e.g.

Parsing

Full parse into a dict of DataFrames (eager):

import stdfast as sf

stdf = sf.parse_stdf("my_stdf.stdf")
stdf["data"]              # polars DataFrame of all test results
stdf["test_information"]  # DataFrame of test metadata
stdf["master_information"]["lot_id"]  # MIR field

Raw record dicts, fully loaded (eager):

import stdfast as sf

records = sf.get_raw_records("my_stdf.stdf")
ptrs = [r for r in records if r["record_type"] == "PTR"]

Pydantic models, fully loaded (eager):

import stdfast as sf

records = sf.get_records("my_stdf.stdf")
failing = [r for r in records if r.record_type == "PTR" and not r.pass_()]

Lazy iteration over raw dicts — memory-efficient for large files:

import stdfast as sf

for record in sf.iter_raw_records("my_stdf.stdf"):
    if record["record_type"] == "PTR":
        print(record["test_num"], record["result"])

Lazy iteration over Pydantic models:

import stdfast as sf

for record in sf.iter_records("my_stdf.stdf"):
    if record.record_type == "PTR":
        print(record.test_num, record.result)

Collect only MIR (file header metadata):

import stdfast as sf

mir = sf.get_mir("my_stdf.stdf")
print(mir["lot_id"], mir["part_typ"])

Writing

Batch write with write_stdf (builds the full list in memory first):

import stdfast as sf
from stdfast.records import FAR, MIR, MRR, PIR, PTR, PRR

records = [
    FAR(cpu_type=2, stdf_ver=4),
    MIR(lot_id="LOT001", part_typ="MYPART", job_nam="MYJOB"),
    PIR(head_num=1, site_num=1),
    PTR(test_num=1000, head_num=1, site_num=1, result=1.23, test_txt="my_test"),
    PRR(head_num=1, site_num=1, hard_bin=1, soft_bin=1, num_test=1),
    MRR(),
]
sf.write_stdf("output.stdf", records)

Streaming write with StdfWriter (flushes each record immediately):

import stdfast as sf
from stdfast.records import FAR, MIR, MRR, PIR, PTR, PRR

# Creates new file or overwrites content if it exists
with sf.StdfWriter("output.stdf", append=False) as w:
    w.write_record(FAR(cpu_type=2, stdf_ver=4))
    w.write_record(MIR(lot_id="LOT001", part_typ="MYPART", job_nam="MYJOB"))
    for i, result in enumerate(my_results):
        w.write_record(PIR(head_num=1, site_num=1))
        w.write_record(PTR(test_num=1000 + i, head_num=1, site_num=1, result=result, test_txt=f"test_{i}"))
        w.write_record(PRR(head_num=1, site_num=1, hard_bin=1, soft_bin=1, num_test=1))
    w.write_record(MRR())

# Creates new file or appends to content if it exists
with sf.StdfWriter("output.stdf", append=True) as w:
    ...

StdfWriter is preferable when the number of records is large or unknown upfront, since it never holds more than one record in memory at a time.

Rust

Parsing

use stdfast::data::STDF;
use polars::prelude::*;

let verbose = false;
if let Ok(stdf) = STDF::from_fname(&fname, verbose) {
    let df: DataFrame = (&stdf.test_data).into();
    let df_fmti: DataFrame = (&stdf.test_data.test_information).into();
    println!("{df:#?}");
    println!("{df_fmti}");
    }

Records is a lazy iterator over RawRecords. Each RawRecord reads from the file but does not parse its contents until .resolve() is called, which returns an Option<Record>. This lets you skip or filter records without paying the parsing cost for every one.

Print every record as ATDF text:

use stdfast::records::Records;

let records = Records::new("my_stdf.stdf")?;
for raw in records {
    if let Some(record) = raw.resolve() {
        println!("{record}");
    }
}

Collect only PTR records, resolving nothing else:

use stdfast::records::{Records, record_impl::Record};

let ptrs: Vec<_> = Records::new("my_stdf.stdf")?
    .filter_map(|raw| raw.resolve())
    .filter_map(|r| if let Record::PTR(ptr) = r { Some(ptr) } else { None })
    .collect();

Count records by type without resolving any:

use stdfast::records::{Records, RecordSummary};

let mut summary = RecordSummary::new();
for raw in Records::new("my_stdf.stdf")? {
    summary.add(&raw);
}
for (rtype, count) in summary {
    println!("{rtype:?}: {count}");
}

Find the first failing PTR:

use stdfast::records::{Records, record_impl::Record};

let first_fail = Records::new("my_stdf.stdf")?
    .filter_map(|raw| raw.resolve())
    .filter_map(|r| if let Record::PTR(ptr) = r { Some(ptr) } else { None })
    .find(|ptr| !ptr.pass());

Installation

There is no cargo or pypi release yet.

Building from source

Rust:

cargo build

Python bindings (requires an active virtualenv):

pip install maturin
maturin develop

Development

If you're seeing issues with pyo3 recompiling on every build, even when there are no pyo3-related changes, then you're most likely running into this issue.

Consider setting the PYO3_PYTHON env variable adding to your Cargo.toml or terminal:

[env]
PYO3_PYTHON = /path/to/python

and also ensuring this is the Python interpreter used by your IDE. E.g. if using nvim, activate the venv before starting nvim.

Project details


Download files

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

Source Distribution

stdfast-0.2.0.tar.gz (77.6 kB view details)

Uploaded Source

Built Distributions

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

stdfast-0.2.0-cp310-abi3-win_amd64.whl (4.8 MB view details)

Uploaded CPython 3.10+Windows x86-64

stdfast-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

stdfast-0.2.0-cp310-abi3-musllinux_1_2_armv7l.whl (5.4 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

stdfast-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

stdfast-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

stdfast-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

stdfast-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

stdfast-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file stdfast-0.2.0.tar.gz.

File metadata

  • Download URL: stdfast-0.2.0.tar.gz
  • Upload date:
  • Size: 77.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a402b83cc44931309bfa8958f8a98df528a84ecabb8ee5cc499532e4ef76852e
MD5 ae8b59fb30df9418700cbe209c5de75b
BLAKE2b-256 ff5067acad6efa7332aa79cf7510ed51fb6b5faf62812df9a728a9e2c022e4d5

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.8 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f015fc8e6a19a0ce209ca9ff337e9afa0584e94597dc136cd7847978bb22294b
MD5 64995566aee8f49a34aab03c263306a6
BLAKE2b-256 a8893113eb76ebb88a9e5106df0703761e9361b8538eb3aa28df99e8890210df

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 5.5 MB
  • Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fab8b93dbd848cf5512e98cbd07794c3a30d8d640467e6ad16b71a02230ba254
MD5 c7e7b50887e6a897dc04661264d6e0b8
BLAKE2b-256 dcdb7894a8a77099bbeb73ee7f80cb1f596398b910d07e8dd07d088c554bcef1

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-musllinux_1_2_armv7l.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-musllinux_1_2_armv7l.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: CPython 3.10+, musllinux: musl 1.2+ ARMv7l
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 15480f63a0001a2310961949c584228f5eb529eeff80e7a0702cc9514c94700e
MD5 09e5c6a6e797b910a685106dd1c72717
BLAKE2b-256 89b66fbbd0b99c1670660a124e0bb23ef6801129bc7b9ed9c852ad376f66d5d2

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 43c005a184cd9fafe9af09ef30f68afcdcf55dfdb7054d78c17e44731e2828ea
MD5 3639e5d60d4ab8fd0cf129cda84221ae
BLAKE2b-256 a63a5d73c4193aa367e9f87616350af1828dae7186ee0bb39b23f5da6ac4013f

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86f1c223e345f4d6fff19ad2ee8c57c645313eae2575223ab19108f5b8f38f9c
MD5 587a48a19efc400b871eee8532c70fc1
BLAKE2b-256 49eb927adeb17d822e224d6b1298739bc392dd8eef65a57344b52f18bab8c8de

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ ARMv7l
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 258d80f4bfb09d4887cc1d98858bb8fec7bbe0e23dfae4f69d257c3b28ab36ff
MD5 557dd910c20fac9daf0637efb1b42d13
BLAKE2b-256 9ad78e58a983762711b34798b7bbaf56375e38d43ad4f1d468be177902244f39

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2d3c27a809779499c0048e3885512f7da4292fb5ec03dad13fadfea2c3012fd7
MD5 2fbe840819b6d07406c6f5877ad2cf64
BLAKE2b-256 ebc5c7a9457707a2f0cae3ccd10a6be806fdacde2f36b85a4fc60191118e1088

See more details on using hashes here.

File details

Details for the file stdfast-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: stdfast-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stdfast-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 839e95806eca06c2401d168126787dc87905f42fd9a1e246251062bc10faafeb
MD5 55d17e945edf204067a1c41ddc28a872
BLAKE2b-256 31ca94569af0d78c0a5aa7ab943da2f5f94cbfe10cda266e5fd4b7e490c2b29a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page