Skip to main content

MILP Snakemake Scheduler Plugin

PyPI version License

A pip-installable scheduler plugin for Snakemake that uses a Mixed-Integer Linear Programming (MILP) scheduler for Snakemake to optimally analyze the jobs for heterogeneous compute resources.

  • milp: schedules only ready jobs via MILP.
  • milp-ext: schedules across all pending jobs using MILP + critical-path analysis.

Features

  • Resource-Aware Scheduling: Considers CPU cores, memory, GPU, custom resources, and I/O constraints.
  • Critical-Path Analysis: Optionally detect and prioritize the longest dependency chain.
  • Historical Estimation: Learns from past executions to refine runtime and I/O size predictions.
  • Multi-Objective Optimization: Balances makespan vs. energy consumption with configurable weights.
  • Graceful Fallbacks: Falls back to greedy or ILP strategies if MILP fails or times out.
  • Plugin Auto-Discovery: Integrates seamlessly via Snakemake entry points.

Installation

From PyPI

pip install milp-snakemake-scheduler

From Source

git clone https://github.com/AasishKumarSharma/milp_snakemake_scheduler.git
cd milp_snakemake_scheduler
pip install .

For development (including test dependencies):

pip install -e .[dev]

Quick Start

  1. Create a System Profile: system_profile.json describes your clusters/nodes.

  2. (Optional) Customize: scheduler_config.yaml to adjust estimation, objectives, and fallbacks.

  3. Run Snakemake:

    3.1. Run in MILP-only mode for ready jobs:

    snakemake --scheduler milp \
              --cores 8 \
              --scheduler-config scheduler_config.yaml \
              --system-profile system_profile.json \
              --jobs 16
    

    3.2. Run in Extended MILP mode with critical-path for a ready jobs in a workflow:

    snakemake --scheduler milp-ext \
              --cores 8 \
              --scheduler-config scheduler_config.yaml \
              --system-profile system_profile.json \
              --jobs 16
    
  4. Dry-Run:

    snakemake --scheduler milp -n --cores 8 --scheduler-config scheduler_config.yaml --system-profile system_profile.json
    

Configuration

system_profile.json

Defines compute clusters and nodes. Example:

{
  "clusters": {
    "local": {
      "nodes": {
        "default": {
          "resources": {"cores": 8, "memory_mb": 32768, "gpu_count": 0},
          "features": ["cpu", "x86_64", "avx2"],
          "properties": {"cpu_flops": 1e11, "memory_bandwidth_mbps": 25600}
        }
      }
    },
    "gpu_cluster": { ... },
    "high_memory": { ... }
  }
}

scheduler_config.yaml

Controls scheduler behavior. Example:

scheduler:
  type: milp
  paths:
    system_profile: system_profile.json
  estimation:
    auto_estimate_file_sizes: true
    history:
      enabled: true
      adaptation_weight: 0.7
  optimization:
    objective_weights:
      makespan: 0.8
      energy: 0.2
    time_limit_seconds: 30
    fallback: greedy

Key options:

  • estimation.auto_estimate_file_sizes: infer I/O if not provided.
  • optimization.time_limit_seconds: MILP solver cutoff.
  • optimization.fallback: greedy or ilp on failure.

Example Snakefile

See example_snakefile.py in this repo. A minimal snippet:

configfile: "scheduler_config.yaml"

rule all:
    input: "results/output.txt"

rule demo:
    output: "results/output.txt"
    threads: 2
    resources:
        mem_mb=1024,
        runtime=5
    params:
        job_specification={
            "features": ["cpu"],
            "resources": {"input_size_mb": 10, "output_size_mb": 5},
            "properties": {"cpu_flops": 1e9}
        }
    shell:
        "echo Hello > {output}"

Testing

Run tests with:

pytest tests/

Include additional tests in tests/ following the existing patterns.


Packaging & Publishing

  • Bump version in setup.py.
  • Tag a release:
git tag v0.1.0
git push --tags
  • Build and upload:
python3 -m build
twine upload dist/*

Contributing

  1. Fork and clone the repo
  2. Create a branch: git checkout -b feature/new-flag
  3. Implement changes and add tests
  4. Ensure all tests pass: pytest
  5. Submit a pull request

Please follow Conventional Commits for commit messages.


License

This project is licensed under the MIT License.

Metadata

Release files for milp-snakemake-scheduler 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for milp-snakemake-scheduler 0.1.1
File Size Uploaded Provenance Actions
milp_snakemake_scheduler-0.1.1.tar.gz 20.3 kB Without provenance Details for milp_snakemake_scheduler-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for milp-snakemake-scheduler 0.1.1
File Interpreter ABI Platform Actions
milp_snakemake_scheduler-0.1.1-py3-none-any.whl Python 3 none any Details for milp_snakemake_scheduler-0.1.1-py3-none-any.whl

Total release size: 37.1 kB

Release files / milp_snakemake_scheduler-0.1.1.tar.gz

Download URL milp_snakemake_scheduler-0.1.1.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
92421ff47c857680bd6b2b5d1bb8926c76bc146fa0bc0d0b71170ae44f0f54f2
BLAKE2b-256 checksum
How to use checksums
c92ba383ff10a8441e8a9883f3c996e4c50a72ff2770ac6b870664a271441555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / milp_snakemake_scheduler-0.1.1-py3-none-any.whl

Download URL milp_snakemake_scheduler-0.1.1-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df6e8438046970e1acc52c3262b7c42c11137a697ad1a71f557556434217922d
BLAKE2b-256 checksum
How to use checksums
324f4e6246efaffb589e7aaf09bd6aa39f224ce027d9cb82a22af5e51f0236c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Security for milp-snakemake-scheduler 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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