Skip to main content

maidkit

Maidkit provides small, typed tools for Python scripts. It keeps each API narrow and avoids application framework features.

  • Python 3.12+
  • Apache-2.0

Installation

pip install maidkit

With uv:

uv add maidkit

Batch jobs

maidkit.batch processes a finite iterable of items on a fixed number of worker threads. It shows progress with Rich and returns results in input order.

import hashlib
from pathlib import Path

from maidkit.batch import TaskContext, run_batch


def hash_file(path: Path, task: TaskContext) -> str:
    digest = hashlib.sha256()
    total = path.stat().st_size

    task.status("hashing")
    with path.open("rb") as source:
        while chunk := source.read(1024 * 1024):
            task.check_cancelled()
            digest.update(chunk)
            task.advance(len(chunk), total=total, unit="bytes")

    return digest.hexdigest()


files = (path for path in Path("input").iterdir() if path.is_file())
result = run_batch(
    files,
    hash_file,
    title="Hash files",
    workers=4,
    label=lambda path: path.name,
)

for item in result.failed:
    print(f"{item.label}: {item.error}")

raise SystemExit(0 if result.ok else 1)

A worker receives one item and a TaskContext. The context lets the worker:

  • Set its status with task.status(...).
  • Report absolute or incremental progress.
  • Check for cancellation with task.check_cancelled().
  • Skip the item with task.skip(...).
  • Run a child process with task.run_process(...).

Each item gets one ItemResult. A normal return succeeds. If a worker raises an exception, the item fails. The batch continues by default.

The display supports single-item and multi-item batches. Redirected output uses stable text instead of live progress.

Batch behavior

  • run_batch reads all items and labels before it starts a worker.
  • It runs at most workers items at the same time.
  • It returns results in input order, even when workers finish in a different order.
  • It stores worker exceptions in failed results instead of raising them.
  • fail_fast=True stops new items after the first failure. Active workers continue.
  • The first Ctrl+C stops scheduling new items and requests cancellation from active workers.

TaskContext.run_process captures stdout and stderr and checks the exit status. Batch cancellation also stops the child process. Output callbacks run in the worker thread and receive one line at a time without its newline.

Metadata

Release files for maidkit 0.1.0

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

Source distribution (sdist)

Source distribution for maidkit 0.1.0
File Size Uploaded Provenance Actions
maidkit-0.1.0.tar.gz 14.5 kB Without provenance Details for maidkit-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for maidkit 0.1.0
File Interpreter ABI Platform Actions
maidkit-0.1.0-py3-none-any.whl Python 3 none any Details for maidkit-0.1.0-py3-none-any.whl

Total release size: 32.9 kB

Release files / maidkit-0.1.0.tar.gz

Download URL maidkit-0.1.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6e6107a26dc330d44e3e779116df1f0261e3323aa337d7c0bb4e0bba9a1fd98e
BLAKE2b-256 checksum
How to use checksums
94341d006840e18dac0b51d63b0d66e26104034617148a3e30ae5fa12e8f43fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / maidkit-0.1.0-py3-none-any.whl

Download URL maidkit-0.1.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
613dd1ae860acac3dae83be4fd3f0bf0cde5b1086ea4d438c16f570b30170539
BLAKE2b-256 checksum
How to use checksums
1549d70fcecc15cfe01d6707b8e73350ef9f29f464949243becae07b8092cbd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for maidkit 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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