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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af777ad201f732a27ef4909e4ee3a401f2e820265425570472deca4b44225ab8
|
|
| MD5 |
3bcd317e3a40bdc64bd7fd87cc8dc812
|
|
| BLAKE2b-256 |
93148f242c2939fc3218552880bab225ef159dc4148234212fd6f4d82f44d265
|
Provenance
The following attestation bundles were made for file_watchman-0.1.0.tar.gz:
Publisher:
publish.yml on ATTMOS/file-watchman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
file_watchman-0.1.0.tar.gz -
Subject digest:
af777ad201f732a27ef4909e4ee3a401f2e820265425570472deca4b44225ab8 - Sigstore transparency entry: 1018794531
- Sigstore integration time:
-
Permalink:
ATTMOS/file-watchman@7a3792ecee0f05d35fae93a8517630e669a22bb6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ATTMOS
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a3792ecee0f05d35fae93a8517630e669a22bb6 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70a4ca750f5b03eb98f63d5a38341549ce6e8e9c089a8bb1225dd8d092a46a64
|
|
| MD5 |
49af62c3ef287276e05f5be262bc190e
|
|
| BLAKE2b-256 |
c5c6b22a7ed80ce873143d578a6659c79462fe4089fc4f89e648419554eeae34
|
Provenance
The following attestation bundles were made for file_watchman-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ATTMOS/file-watchman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
file_watchman-0.1.0-py3-none-any.whl -
Subject digest:
70a4ca750f5b03eb98f63d5a38341549ce6e8e9c089a8bb1225dd8d092a46a64 - Sigstore transparency entry: 1018794550
- Sigstore integration time:
-
Permalink:
ATTMOS/file-watchman@7a3792ecee0f05d35fae93a8517630e669a22bb6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ATTMOS
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a3792ecee0f05d35fae93a8517630e669a22bb6 -
Trigger Event:
release
-
Statement type: