Skip to main content

Lightweight complete run and individual stage tracker for modularized pipelines

Project description

stage-tracker

A lightweight, zero-dependency Python library for tracking multi-stage pipeline executions.
stage-tracker helps developers log structured run metadata, track stage durations, and debug complex flows — all with minimal effort.


📦 What is stage-tracker?

When you're running a pipeline — whether in AI research, cybersecurity defense, data processing, or experimentation — it's critical to:

  • Capture what ran
  • When it ran
  • How long it took
  • What went wrong (or right)

stage-tracker simplifies this with structured JSON output that records:

  • Pipeline-level metadata (e.g., run ID, args, start/end time)
  • Named stages, each with start time, duration, output data, and error info

This makes your system observable, auditable, and debuggable.


✨ Features

  • 🔹 UUID-based run_id for traceability
  • 🕒 ISO-formatted timestamps with timezone
  • 📊 Track multiple stages independently or sequentially
  • 💥 Record exception/error messages per stage
  • 📁 Save output as a structured JSON file
  • 🧼 Minimal, clean API with no third-party dependencies

🧑‍💻 Installation

pip install -e .
# Or using uv (recommended)
uv pip install -e .

🚀 Quick Start

from stage_tracker import Tracker

# Initialize a tracker for a given run
tracker = Tracker(args="Reconnaissance_M1")

# Track stages
tracker.start_stage("Detection")
# ... run detection logic ...
tracker.end_stage("Detection", data={"status": "clean"})

tracker.start_stage("Enrichment")
# ... enrichment logic ...
tracker.end_stage("Enrichment", data={"added_cves": 3})

# Finalize and save
tracker.finalize("run_output.json")

Output (run_output.json):

{
  "run_id": "af3c980c-3d22-46e8-83cd-7ff99abee586",
  "start_time": "2025-05-05T23:14:10.235518+00:00",
  "args": "Reconnaissance_M1",
  "stages": {
    "Detection": {
      "start_time": "...",
      "duration_sec": 3.42,
      "data": {"status": "clean"},
      "error": null
    },
    "Enrichment": {
      "start_time": "...",
      "duration_sec": 1.01,
      "data": {"added_cves": 3},
      "error": null
    }
  },
  "completed_at": "...",
  "total_duration_sec": 9.42
}

🧩 Use Cases

  • 🔍 AI/ML Experiments: Measure durations of preprocessing, training, evaluation.
  • 🛡 Cybersecurity Pipelines: Log detection, enrichment, and mitigation stages.
  • ⚙️ ETL/Batch Jobs: Trace and debug stage-level runtime or failures.
  • 📄 Paper Reproducibility: Attach structured logs for each experiment run.

🛠 How It Works

  1. Instantiate Tracker(args=...)
  2. For each stage:
    • Call start_stage("StageName")
    • Run logic
    • Call end_stage("StageName", data=..., error=...)
  3. When done, call tracker.finalize("output.json")

Internally, it tracks timestamps, computes durations, and writes JSON output.


📂 Project Structure

stage-tracker/
├── stage_tracker/
│   ├── __init__.py
│   └── tracker.py
├── pyproject.toml
├── LICENSE
└── README.md

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.


🤝 Contributing

Pull requests are welcome. Feel free to fork and improve! If you find a bug or want to request a feature, please open an issue and I'll do my best to review and address issues promptly.


📬 Contact

Maintained by Karim Ahmed.
Email: karim.ahmed4815@gmail.com GitHub: rexmirak

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

stage_tracker-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

stage_tracker-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stage_tracker-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for stage_tracker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0151b7f256af35df0d1eb7cb054ca22eab3b9465d1571a49a9949ae71267921e
MD5 e0294160464118959e64a5304970817f
BLAKE2b-256 b705226a7c2d039ed5b597366933b53c783b3858ba30934c5b87b56932509f9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stage_tracker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for stage_tracker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efd1ff8268a31d917dbd408543c628273a5e6252534c57bc7accfc269dbc0e1b
MD5 6470122b98f1fcab447fbe1bcc7f52dc
BLAKE2b-256 711aa8891c984527c1de2623019452f4158ca3739edaa560ef8941cc111d477c

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