Skip to main content

Work directory manifest and delta library

Project description

file-watchman

A Python library that scans work directories, produces JSON manifests, and computes file-level deltas for incremental uploads and workflow monitoring.

Features

  • Directory scanning — walk a directory tree with configurable include/exclude glob rules
  • Manifest snapshots — deterministic, sorted JSON manifests with file metadata
  • Delta computation — detect new, changed, and deleted files between snapshots
  • Category-driven hashing — SHA-256 for critical files (checkpoints), skip for large files (trajectories)
  • Atomic writes — safe manifest persistence via tmp + fsync + rename
  • Zero runtime dependencies — stdlib only, Python 3.10+

Installation

From GitHub:

pip install git+https://github.com/ATTMOS/file-watchman.git

For development:

git clone https://github.com/ATTMOS/file-watchman.git
cd file-watchman
pip install -e ".[dev]"

Quick Start

from file_watchman import (
    ScanRules,
    HashPolicy,
    scan_manifest,
    diff_manifests,
    load_manifest,
    write_manifest_atomic,
)

# Configure scan rules
rules = ScanRules(
    includes=["**/*"],
    excludes=[".git/**", "**/__pycache__/**", "**/*.tmp"],
    max_files=50000,
)

# Configure hashing policy
hash_policy = HashPolicy(
    required_categories={"checkpoint", "restart"},
    optional_categories={"log"},
    never_categories={"trajectory"},
    max_hash_bytes=512 * 1024 * 1024,
)

# Scan a directory
manifest_new = scan_manifest(
    root="/scratch/job_123",
    rules=rules,
    hash_policy=hash_policy,
    job_id="job-123",
)

# Compare with a previous manifest
manifest_prev = load_manifest("/scratch/job_123/manifest_prev.json")
delta = diff_manifests(manifest_prev, manifest_new)

print(f"Uploads: {len(delta.uploads)}, Deletions: {len(delta.deletions)}")

# Persist the new manifest atomically
write_manifest_atomic("/scratch/job_123/manifest_new.json", manifest_new)

Custom Categorization

Assign categories to files using glob-based rules:

from file_watchman.rules import make_categorizer

categorize = make_categorizer([
    ("**/cpt_*.pkl", "checkpoint"),
    ("**/*.rst7", "restart"),
    ("**/*.log", "log"),
    ("**/*.nc", "trajectory"),
])

manifest = scan_manifest(
    root="/scratch/job_123",
    rules=rules,
    hash_policy=hash_policy,
    categorize=categorize,
)

Files not matching any rule default to the "other" category.

API Reference

See docs/api.md for the complete API reference.

License

MIT

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

file_watchman-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

file_watchman-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for file_watchman-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af777ad201f732a27ef4909e4ee3a401f2e820265425570472deca4b44225ab8
MD5 3bcd317e3a40bdc64bd7fd87cc8dc812
BLAKE2b-256 93148f242c2939fc3218552880bab225ef159dc4148234212fd6f4d82f44d265

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ATTMOS/file-watchman

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

File details

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

File metadata

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

File hashes

Hashes for file_watchman-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70a4ca750f5b03eb98f63d5a38341549ce6e8e9c089a8bb1225dd8d092a46a64
MD5 49af62c3ef287276e05f5be262bc190e
BLAKE2b-256 c5c6b22a7ed80ce873143d578a6659c79462fe4089fc4f89e648419554eeae34

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ATTMOS/file-watchman

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