quickslurm


Namequickslurm JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryA lightweight Python wrapper for Slurm sbatch/srun with robust subprocess handling and optional logging.
upload_time2025-08-15 18:21:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 QuickSlurm - Authors: Jack Quimby and Alex Buettner Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cluster hpc quick quickslurm sbatch slurm srun wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # quickslurm
[![Lint/Test](https://github.com/quickslurm/quickslurm/actions/workflows/lint-and-pytest.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/lint-and-pytest.yml)
[![Build/Publish](https://github.com/quickslurm/quickslurm/actions/workflows/build-and-publish-to-pypi.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/build-and-publish-to-pypi.yml.yml)
[![Docs](https://github.com/quickslurm/quickslurm/actions/workflows/generate-docs.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/generate-docs.yml)

[![PyPI](https://img.shields.io/pypi/v/quickslurm)](https://pypi.org/project/quickslurm/)
[![Python versions](https://img.shields.io/pypi/pyversions/quickslurm)](https://pypi.org/project/quickslurm/)
[![License](https://img.shields.io/github/license/quickslurm/quickslurm)](https://github.com/quickslurm/quickslurm/blob/main/LICENSE)


A lightweight Python wrapper around Slurm for:

- Submitting batch jobs (sbatch)
- Running commands (srun)
- Cancelling jobs (scancel)

It focuses on safe subprocess handling, simple ergonomics, and sensible defaults.

Full documentation can be found here: [Quickslurm Docs](https://quickslurm.github.io/quickslurm/)

## Features

- sbatch and srun helpers with consistent argument handling
- Optional built-in logging (file and stderr)
- Pass-through environment variables (base and per-call overrides)
- Convenience for inline sbatch scripts
- Optional wait for job completion after sbatch submission

---

## Installation

- Requires Python 3.8+
- Requires Slurm 23.02+ be installed on the system
- Assumes Slurm binaries (sbatch, srun, scancel, sacct if using wait) are on PATH

```shell script
pip install quickslurm
```

---

## Quick start

```python
from quickslurm import Slurm, SlurmError

slurm = Slurm(enable_logging=True)

# Submit an existing script
submit = slurm.sbatch(
    script_path="train.sh",
    sbatch_options={
        "job-name": "trainA",
        "time": "00:30:00",
        "partition": "short",
        "cpus-per-task": 4,
        "mem": "8G",
        "output": "slurm-%j.out",
    },
    script_args=["--epochs", "10"],
)
print("Job ID:", submit.job_id)

# Submit an inline command (temp script will be generated)
submit2 = slurm.submit_inline(
    command=["python", "train.py", "--epochs", "5"],
    sbatch_options={"time": "00:10:00", "job-name": "quick-train"},
)
print("Inline Job ID:", submit2.job_id)

# Run something via srun (non-interactive)
res = slurm.run(["hostname"], srun_options={"ntasks": 1})
print("Hostname:", res.stdout.strip())

# Cancel a job
slurm.cancel(submit2.job_id)
```

Sample output:

```
Job ID: 12300008
Inline Job ID: 12300009
Hostname: testnode1
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "quickslurm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cluster, hpc, quick, quickslurm, sbatch, slurm, srun, wrapper",
    "author": null,
    "author_email": "Alex Buettner <alex.buettner93@gmail.com>, Jack Quimby <jack.quimby54@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/85/96/d92a89e62c450b14e42f54bf7bb9b0760fd326cd63f2b6cef1295bbaddaa/quickslurm-0.1.4.tar.gz",
    "platform": null,
    "description": "# quickslurm\n[![Lint/Test](https://github.com/quickslurm/quickslurm/actions/workflows/lint-and-pytest.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/lint-and-pytest.yml)\n[![Build/Publish](https://github.com/quickslurm/quickslurm/actions/workflows/build-and-publish-to-pypi.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/build-and-publish-to-pypi.yml.yml)\n[![Docs](https://github.com/quickslurm/quickslurm/actions/workflows/generate-docs.yml/badge.svg?branch=main)](https://github.com/quickslurm/quickslurm/actions/workflows/generate-docs.yml)\n\n[![PyPI](https://img.shields.io/pypi/v/quickslurm)](https://pypi.org/project/quickslurm/)\n[![Python versions](https://img.shields.io/pypi/pyversions/quickslurm)](https://pypi.org/project/quickslurm/)\n[![License](https://img.shields.io/github/license/quickslurm/quickslurm)](https://github.com/quickslurm/quickslurm/blob/main/LICENSE)\n\n\nA lightweight Python wrapper around Slurm for:\n\n- Submitting batch jobs (sbatch)\n- Running commands (srun)\n- Cancelling jobs (scancel)\n\nIt focuses on safe subprocess handling, simple ergonomics, and sensible defaults.\n\nFull documentation can be found here: [Quickslurm Docs](https://quickslurm.github.io/quickslurm/)\n\n## Features\n\n- sbatch and srun helpers with consistent argument handling\n- Optional built-in logging (file and stderr)\n- Pass-through environment variables (base and per-call overrides)\n- Convenience for inline sbatch scripts\n- Optional wait for job completion after sbatch submission\n\n---\n\n## Installation\n\n- Requires Python 3.8+\n- Requires Slurm 23.02+ be installed on the system\n- Assumes Slurm binaries (sbatch, srun, scancel, sacct if using wait) are on PATH\n\n```shell script\npip install quickslurm\n```\n\n---\n\n## Quick start\n\n```python\nfrom quickslurm import Slurm, SlurmError\n\nslurm = Slurm(enable_logging=True)\n\n# Submit an existing script\nsubmit = slurm.sbatch(\n    script_path=\"train.sh\",\n    sbatch_options={\n        \"job-name\": \"trainA\",\n        \"time\": \"00:30:00\",\n        \"partition\": \"short\",\n        \"cpus-per-task\": 4,\n        \"mem\": \"8G\",\n        \"output\": \"slurm-%j.out\",\n    },\n    script_args=[\"--epochs\", \"10\"],\n)\nprint(\"Job ID:\", submit.job_id)\n\n# Submit an inline command (temp script will be generated)\nsubmit2 = slurm.submit_inline(\n    command=[\"python\", \"train.py\", \"--epochs\", \"5\"],\n    sbatch_options={\"time\": \"00:10:00\", \"job-name\": \"quick-train\"},\n)\nprint(\"Inline Job ID:\", submit2.job_id)\n\n# Run something via srun (non-interactive)\nres = slurm.run([\"hostname\"], srun_options={\"ntasks\": 1})\nprint(\"Hostname:\", res.stdout.strip())\n\n# Cancel a job\nslurm.cancel(submit2.job_id)\n```\n\nSample output:\n\n```\nJob ID: 12300008\nInline Job ID: 12300009\nHostname: testnode1\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 QuickSlurm - Authors: Jack Quimby and Alex Buettner\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A lightweight Python wrapper for Slurm sbatch/srun with robust subprocess handling and optional logging.",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/JayQuimby/quickslurm",
        "Issues": "https://github.com/JayQuimby/quickslurm/issues",
        "Repository": "https://github.com/JayQuimby/quickslurm"
    },
    "split_keywords": [
        "cluster",
        " hpc",
        " quick",
        " quickslurm",
        " sbatch",
        " slurm",
        " srun",
        " wrapper"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9918fbd254c852a6ef638a40c9c6d508b66efebf3b898b478de96fe04fa1bf9c",
                "md5": "9b10fca4c9e90704ec3d691830defad6",
                "sha256": "7fcf2ec12fcb35758bbba2fab448ae8d67623b32ef0a455b41995cbb31588f4c"
            },
            "downloads": -1,
            "filename": "quickslurm-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9b10fca4c9e90704ec3d691830defad6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12111,
            "upload_time": "2025-08-15T18:21:46",
            "upload_time_iso_8601": "2025-08-15T18:21:46.169878Z",
            "url": "https://files.pythonhosted.org/packages/99/18/fbd254c852a6ef638a40c9c6d508b66efebf3b898b478de96fe04fa1bf9c/quickslurm-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8596d92a89e62c450b14e42f54bf7bb9b0760fd326cd63f2b6cef1295bbaddaa",
                "md5": "e409eaec155da9a5332f97b0f30f69c8",
                "sha256": "a3cb466be4034ee8ab7cbe4f82d344d044c3ddeb25f9245eb55c0aa2cbdede08"
            },
            "downloads": -1,
            "filename": "quickslurm-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e409eaec155da9a5332f97b0f30f69c8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13106,
            "upload_time": "2025-08-15T18:21:47",
            "upload_time_iso_8601": "2025-08-15T18:21:47.324099Z",
            "url": "https://files.pythonhosted.org/packages/85/96/d92a89e62c450b14e42f54bf7bb9b0760fd326cd63f2b6cef1295bbaddaa/quickslurm-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 18:21:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JayQuimby",
    "github_project": "quickslurm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "quickslurm"
}
        
Elapsed time: 0.42515s