Skip to main content

jps-slurm-utils

Build Publish to PyPI codecov

Audit/evaluate SLURM HPC jobs by parsing static artifacts (stdout/stderr/log/config files) and producing human- and machine-readable reports.

🚀 Overview

jps-slurm-job-audit is a powerful offline SLURM job audit tool that analyzes job artifacts without requiring cluster access. It provides:

  • Automated failure detection: Detects OOM errors, timeouts, segfaults, Python/Java/R exceptions, filesystem errors, and more
  • Metadata extraction: Parses SBATCH directives and job information from scripts and filenames
  • Resource utilization tracking: Extracts metrics from seff/sacct outputs when available
  • Structured reporting: Generates JSON reports with evidence snippets and remediation guidance
  • Batch processing: Analyze hundreds of jobs and generate aggregate summaries
  • Exit codes: 0=OK, 1=WARN, 2=FAIL, 3+=tool error

Features

  • ✅ Offline analysis - No cluster access needed, works with copied artifacts
  • ✅ Pattern-based detection - Built-in rules for common HPC failure modes
  • ✅ Streaming scanner - Efficiently handles large log files without loading into memory
  • ✅ Evidence capture - Stores relevant log excerpts with line numbers and context
  • ✅ Configurable discovery - Flexible glob/regex patterns for file matching
  • ✅ Rich terminal output - Pretty tables and color-coded summaries
  • ✅ Machine-readable reports - JSON/CSV outputs for downstream analytics
  • ✅ Extensible - Plugin architecture for custom detectors (future milestone)

Example Usage

Audit a single job directory:

jps-slurm-job-audit single --job-dir /path/to/job/artifacts

Output:

INFO: Starting audit of job directory: /path/to/job/artifacts
INFO: Phase 1: Discovering artifacts...
INFO: Discovered 5 files in /path/to/job/artifacts
INFO: Phase 2: Extracting metadata...
INFO: Phase 3: Detecting failure patterns...
INFO: Found 2 issues across 2 files
INFO: Phase 4: Extracting metrics...
INFO: Phase 5: Computing final status...
INFO: Audit complete. Status: FAIL, Score: 40

✓ Audit complete!
Report saved to: /tmp/user/jps-slurm-job-audit/20240115_142330/report.json

┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Field        ┃ Value          ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ Job ID       │ 123456         │
│ Job Name     │ example_job    │
│ Status       │ FAIL           │
│ Findings     │ 2              │
│ Files Scanned│ 5              │
└──────────────┴────────────────┘

Findings:
  • Python Exception: Detected python exception in example-123456.out (1 occurrences)
  • Out of Memory: Detected out of memory in slurm-654321.out (3 occurrences)

Audit multiple jobs in batch:

# Create a file with job directory paths
cat > job_dirs.txt <<EOF
/path/to/job1
/path/to/job2
/path/to/job3
EOF

jps-slurm-job-audit batch --path-list job_dirs.txt --outdir ./results

Advanced filtering:

# Only scan specific file types
jps-slurm-job-audit single --job-dir ./job --glob "*.out"

# Include/exclude patterns
jps-slurm-job-audit single --job-dir ./job \
  --include "slurm-.*\.(out|err)" \
  --exclude "backup"

# Custom output location
jps-slurm-job-audit single --job-dir ./job \
  --outdir ./my-reports \
  --logfile ./my-reports/audit.log

# Verbose logging
jps-slurm-job-audit single --job-dir ./job --verbose

# Quiet mode (no console output)
jps-slurm-job-audit single --job-dir ./job --quiet

Batch with filtering:

# Only show failed jobs
jps-slurm-job-audit batch --path-list jobs.txt --only FAIL

Report Structure

The JSON report includes:

{
  "tool_version": "0.1.0",
  "run_timestamp": "2024-01-15T14:23:30",
  "job_metadata": {
    "job_id": "123456",
    "job_name": "example_job",
    "partition": "compute",
    "nodes": 2,
    "ntasks": 16,
    "cpus_per_task": 2,
    "mem": "64G",
    "time_limit": "12:00:00"
  },
  "discovered_files": [...],
  "findings": [
    {
      "id": "python_exception_example-123456.out",
      "category": "Python Exception",
      "severity": "ERROR",
      "message": "Detected python exception in example-123456.out (1 occurrences)",
      "confidence": 0.9,
      "remediation": "Review Python traceback and fix the reported error in your code.",
      "evidence": [
        {
          "file": "/path/to/example-123456.out",
          "line_start": 12,
          "excerpt": "ValueError: invalid literal for int() with base 10: 'NaN'",
          "match_pattern": "(?i)^\\w+Error:",
          "context_before": [
            "  File \"/path/to/application.py\", line 156, in process_data",
            "    result = transform(data)"
          ]
        }
      ]
    }
  ],
  "metrics": {
    "walltime_used": "00:45:23",
    "memory_utilized": "58.2 GB",
    "cpu_efficiency": 87.5
  },
  "final_status": "FAIL",
  "score": 40,
  "rules_used": ["built-in"]
}

📦 Installation

From source:

git clone https://github.com/jai-python3/jps-slurm-utils
cd jps-slurm-utils
make install

Using pip (when published):

pip install jps-slurm-utils

For development:

make install-dev

🧪 Development

# Format and lint code
make fix && make format && make lint

# Run tests
make test

# Run tests with coverage
make test-cov

# Run all checks
make all

🗺️ Roadmap

This implements Milestones 0-4 from the SRS:

  • ✅ Project skeleton with Typer CLI
  • ✅ Artifact discovery and metadata normalization
  • ✅ Error/failure classification with evidence capture
  • ✅ Resource utilization inference with anomaly detection
  • ✅ External YAML rule packs with remediation guidance

Future milestones:

  • Milestone 5: Batch aggregation analytics
  • Milestone 6: Job comparison/diff command
  • Milestone 7: Plugin architecture

🤝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass (make test)
  5. Submit a pull request

📜 License

MIT License © Jaideep Sundaram

Metadata

Release files for jps-slurm-utils 0.3.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 jps-slurm-utils 0.3.0
File Size Uploaded
jps_slurm_utils-0.3.0.tar.gz 35.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jps-slurm-utils 0.3.0
File Interpreter ABI Platform
jps_slurm_utils-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.9 kB

Release files / jps_slurm_utils-0.3.0.tar.gz

Download URL jps_slurm_utils-0.3.0.tar.gz
Size 35.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb281feca7e95453bef66e7fd5055c5589f211031b965c2bfc135c3523e0a4b2
BLAKE2b-256 checksum
How to use checksums
5580f27f862c73f1b4ab1f65df0820ddef329be7e206156f5193b3f068c94730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / jps_slurm_utils-0.3.0-py3-none-any.whl

Download URL jps_slurm_utils-0.3.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9521ffb8d20952ea9226a625ab2cb1527fe5ccac7c8a5ac310c1215c9feb854b
BLAKE2b-256 checksum
How to use checksums
8956c63e90b0fb9b123a5144df05bc548476bdb42034eb71d18c84c551fc3832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

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