idmtools-platform-slurm
- Introduction
- Setting Up Virtual Environment
- Development Tips
- Manually run a script as a Slurm job
- Use SlurmJob to run a script as a Slurm job
- With SlurmPlatform to run a script as a Slurm job
- Folder structure:
Introduction
SlurmPlatform is a platform designed to facilitate the execution of experiments and simulations in slurm cluster.
Setting Up Virtual Environment
To set up a virtual environment for SlurmPlatform, follow these steps:
-
Install Python
Ensure you have Python 3.8+ installed on your system.
-
Create Virtual Environment
There are multiple ways to create a virtual environment. Below is an example using
venv:python -m venv slurm_env
-
Activate Virtual Environment
- On Windows:
slurm_env\Scripts\activate
- On Linux:
source slurm_env/bin/activate
- On Windows:
-
Install SlurmPlatform
pip install idmtools-platform-slurm
-
Install Dependencies
pip install -r requirements.txt
-
Optional(No need step #4 and #5), Install all slurm platform related packages
pip install idmtools[slurm]
Development Tips
There is a Makefile file available for most common development tasks. Here is a list of commands
clean - Clean up temproary files
lint - Lint package and tests
test - Run All tests
coverage - Run tests and generate coverage report that is shown in browser
On Windows, you can use pymake instead of make
Manually run a script as a Slurm job
Preparation
(1).Have target script ready, say my_script.py, suppose you have folder structure like::
script_folder
my_script.py
......
(2). Created a virtual environment and activated it.
Steps
- within the target script folder, create a batch file 'sbatch.sh' (without quote) with content:
#!/bin/bash
#SBATCH --partition=b1139
#SBATCH --time=10:00:00
#SBATCH --account=b1139
#SBATCH --output=stdout.txt
#SBATCH --error=stderr.txt
# replace with your script file
python3 my_script.py
exit $RESULT
Note: the content here is based on Northwestern University QUEST Slurm system. For general case, above content (required #SBATCH parameters) may be a little bit different.
-
run your target script as SLURM job execute the following commands from console (under virtual environment):
cd path_to_script_folder
sbatch sbatch.sh
Note: any output information from my_script.py is stored in file stdout.txt under the current folder. For example, if my_script.py kicks out another Slurm job, then its Slurm id information can be found in file stdout.txt.
Use SlurmJob to run a script as a Slurm job
The example can be simple as the following:
--script.py--
from idmtools.core.platform_factory import Platform
from idmtools_platform_slurm.utils.slurm_job.slurm_job import SlurmJob
script = '<user script path>'
# script = 'example_path/python_sim_slurm.py' # example
platform = Platform('SLURM_LOCAL', job_directory='<job_directory>')
sj = SlurmJob(script_path=script, platform=platform)
sj.run()
With SlurmPlatform to run a script as a Slurm job
We have SlurmJob integrated into SlurmPlatform and any Python script can run as a Slurm job simply doing:
--script.py--
from idmtools.entities.command_task import CommandTask
from idmtools.entities.experiment import Experiment
from idmtools.core.platform_factory import Platform
platform = Platform('SLURM_LOCAL', job_directory='<job_directory>')
# Define task
command = "echo 'Hello, World!'"
task = CommandTask(command=command)
# Run an experiment
experiment = Experiment.from_task(task, name="example")
experiment.run(platform=platform)
Folder structure:
Metadata
Release files for idmtools-platform-slurm 3.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| idmtools_platform_slurm-3.1.2.tar.gz | 47.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| idmtools_platform_slurm-3.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 87.8 kB
Release files / idmtools_platform_slurm-3.1.2.tar.gz
| Download URL | idmtools_platform_slurm-3.1.2.tar.gz |
|---|---|
| Size | 47.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2c82fc9ba209ef33d70782f1998c7423cee7d692ba56ee48a681db7ca393adf
|
|
BLAKE2b-256 checksum How to use checksums |
1cb110a1659d4d128bf0092b0e9f6a69831a763fbc43e5b5c4460cb71fbf9ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / idmtools_platform_slurm-3.1.2-py3-none-any.whl
| Download URL | idmtools_platform_slurm-3.1.2-py3-none-any.whl |
|---|---|
| Size | 39.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
389ffd07686fc2830125fd2146cf838466daba16105d1e7dc148d6ca2ca0edcf
|
|
BLAKE2b-256 checksum How to use checksums |
2621ad7c4acae0b138b3985e413fd00db9a59f58b3f5fcfed13bdf5a9be5a787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency log