Skip to main content

Incremental file processing with persistent savepoints.

Project description

rprocess

rprocess provides glob_rprocessor, a utility to process files matched by a glob pattern with persistent savepoints.

The savepoint file stores per-file results keyed by content hash. This makes reruns faster when files are unchanged, and supports incremental recovery when interruptions happen.

Installation

pip install rprocess

Quick Start

from rprocess import glob_rprocessor


def parse_file(path: str) -> int:
	with open(path, "r", encoding="utf-8") as f:
		return len(f.read())


def collect(total, current):
	if total is None:
		return current
	return total + current


total_chars = glob_rprocessor(
	pathname="data/**/*.txt",
	file_function=parse_file,
	safepoint_path=".rprocess.savepoint.pkl",
	cumulative_function=collect,
	recursive=True,
	increment_savepoint=True,
)

print(total_chars)

How Savepoints Work

  1. Each matched file is hashed using SHA-256.
  2. If the hash already exists in the savepoint, the previous result is reused.
  3. If it is new, file_function(path) runs and the result is cached.
  4. Savepoint entries for files that no longer exist in the glob result are removed.

This enables fast incremental processing because unchanged files are skipped.

Interruption and Incremental Recovery

Use increment_savepoint=True to write the savepoint after each newly processed file.

This is useful for long-running jobs:

  • If execution is interrupted, progress from already-processed files is preserved.
  • The next run resumes with cached results for files completed before the interruption.

If increment_savepoint=False (default), savepoint updates are written at the end when changes occurred.

API

glob_rprocessor(
	pathname,
	file_function,
	safepoint_path,
	cumulative_function=None,
	root_dir=None,
	dir_fd=None,
	recursive=False,
	verbose=False,
	increment_savepoint=False,
)
  • pathname: glob pattern to select files.
  • file_function: function called per file path.
  • safepoint_path: pickle file path used to persist cached results.
  • cumulative_function: optional reducer that combines per-file outputs.
  • recursive: enable recursive glob patterns like **.
  • verbose: print progress and savepoint maintenance messages.
  • increment_savepoint: write savepoint after each new file result.

Development

python -m pip install --upgrade build twine pytest
python -m pytest
python -m build
python -m twine check dist/*

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

rprocess-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

rprocess-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file rprocess-0.1.0.tar.gz.

File metadata

  • Download URL: rprocess-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rprocess-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15f900d2a05995c06e62c29ac63d229b6d70362449845852623ead0843e855e4
MD5 fd81b67941a546cc8f5f0a13e3563f1f
BLAKE2b-256 4e1a4c104a8c97b4ddf37aea9d7169ab09652433aa57d6a0398511ad1da51fea

See more details on using hashes here.

Provenance

The following attestation bundles were made for rprocess-0.1.0.tar.gz:

Publisher: publish.yml on Cutyno/rprocess

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

File details

Details for the file rprocess-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rprocess-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rprocess-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55db9a55f00e62d4ec8e109b36089a5e3435841f2bcfc20368316dced2187111
MD5 b7736fc87fdbdee428f05e2951b90977
BLAKE2b-256 c3f386d3a1b74b5d82527d2b171106b71b87e23b51d2fd6f6f417af6768f1098

See more details on using hashes here.

Provenance

The following attestation bundles were made for rprocess-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Cutyno/rprocess

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

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