Skip to main content

Utilities and APIs for interfacing with the Slurm workload manager.

Project description

slurmutils

PyPI - Version PyPI - Downloads GitHub License Matrix

Utilities and APIs for interfacing with the Slurm workload manager.

slurmutils is a collection of various utilities that make it easier for you and your friends to interface with the Slurm workload manager, especially if you are orchestrating deployments of new and current Slurm clusters. Gone are the days of seething over incomplete Jinja2 templates. Current utilities shipped in the slurmutils package include:

from slurmutils import ...

  • calculate_rs: A function for calculating the ranges and strides of an iterable with unique elements. This function can be used to help convert arrays of node hostnames, device file ids, etc into a Slurm hostname specification.
  • acctgatherconfig: An editor for acct_gather.conf configuration files.
  • cgroupconfig: An editor for cgroup.conf configuration files.
  • gresconfig: An editor for gres.conf configuration files.
  • ociconfig: An editor for oci.conf configuration files.
  • slurmconfig: An editor for slurm.conf configuration files.
  • slurmdbdconfig: An editor for slurmdbd.conf configuration files.

For more information on how to use or contribute to slurmutils, check out the Getting Started and Development sections below 👇

✨ Getting Started

Installation

Option 1: Install from PyPI

$ python3 -m pip install slurmutils

Option 2: Install from source

$ pip install .

Usage

slurmutils

The top-level provides access to some utilities that streamline common Slurm-related operations such as calculating the ranges and strides for a Slurm hostname specification or editing configuration files in-place. Here's some example operations you can perform with these utilities:

calculate_rs
Calculate a range and/or stride from a list of node hostnames
from os.path import commonprefix

from slurmutils import calculate_rs

nodes = ["juju-abc654-1", "juju-abc654-2", "juju-abc654-4"]
prefix = commonprefix(nodes)
nums = [int(n.partition(prefix)[2]) for n in nodes]
slurm_host_spec = prefix + calculate_rs(nums)  # "juju-abc654-[1-2,4]"
Calculate a device file range for Nvidia GPUs
from pathlib import Path

from slurmutils import calculate_rs

device_files = [file for file in Path("/dev").iterdir() if "nvidia" in file.name]
prefix = "/dev/nvidia"
nums = [int(n.partition(prefix)[2]) for n in device_files]
file_spec = prefix + calculate_rs(nums)  # "/dev/nvidia[0-4]"
acctgatherconfig
Edit a pre-existing acct_gather.conf configuration file
from slurmutils import acctgatherconfig

with acctgatherconfig.edit("/etc/slurm/acct_gather.conf") as config:
    config.profile_influxdb_database = "test_acct_gather_db"
    config.profile_influxdb_default = ["none"]
    config.profile_influxdb_host = "testhostname1"
    config.profile_influxdb_pass = "testpassword1"
    config.profile_influxdb_rt_policy = "testpolicy1"
    config.profile_influxdb_user = "testuser1"
    config.profile_influxdb_timeout = 20
cgroupconfig
Edit a pre-existing cgroup.conf configuration file
from slurmutils import cgroupconfig

with cgroupconfig.edit("/etc/slurm/cgroup.conf") as config:
    config.constrain_cores = True
    config.constrain_devices = True
    config.constrain_ram_space = True
    config.constrain_swap_space = True
gresconfig
Edit a pre-existing gres.conf configuration file
from slurmutils import Gres, GresList, gresconfig

with gresconfig.edit("/etc/slurm/gres.conf") as config:
    gres1 = Gres(
        name="gpu",
        type="epyc",
        file="/dev/amd4",
        cores=[0, 1],
    )
    gres2 = Gres(
        name="gpu",
        nodename="juju-abc654-[1-20]",
        type="epyc",
        file="/dev/amd[0-3]",
        count="12G",
    )
    config.auto_detect = "rsmi"
    config.gres["gpu"] = GresList(gres1, gres2)
ociconfig
Edit a pre-existing oci.conf configuration file
from slurmutils import ociconfig

with ociconfig.edit("/etc/slurm/oci.conf") as config:
    config.ignore_file_config_json = False
    config.env_exclude = "^(SLURM_CONF|SLURM_CONF_SERVER|SLURM_JWT)="
    config.create_env_file = "newline"
    config.std_io_debug = "debug"
    config.syslog_debug = "debug"
slurmconfig
Edit a pre-existing slurm.conf configuration file
from slurmutils import slurmconfig

with slurmconfig.edit("/etc/slurm/slurm.conf") as config:
    del config.inactive_limit
    config.max_job_count = 20000
    config.proctrack_type = "proctrack/linuxproc"
Add a new node to the slurm.conf file
from slurmutils import Node, slurmconfig

with slurmconfig.edit("/etc/slurm/slurm.conf") as config:
    node = Node(
        nodename="batch-[0-25]",
        nodeaddr="12.34.56.78",
        cpus=1,
        realmemory=1000,
        tmpdisk=10000,
    )
    config.nodes[node.node_name] = node
slurmdbdconfig
Edit a pre-existing slurmdbd.conf configuration file
from slurmutils import slurmdbdconfig

with slurmdbdconfig.edit("/etc/slurm/slurmdbd.conf") as config:
    config.archive_usage = True
    config.log_file = "/var/spool/slurmdbd.log"
    config.debug_flags = ["db_event", "db_job", "db_usage"]
    del config.auth_alt_types
    del config.auth_alt_parameters

🤔 What's next?

If you want to learn more about all the things you can do with slurmutils, here are some further resources for you to explore:

🛠️ Development

The project uses just and uv for development, which provides some useful commands that will help you while hacking on slurmutils:

just fmt          # Apply formatting standards to code
just lint         # Check code against coding style standards
just typecheck    # Run static type checks
just unit         # Run unit tests

If you're interested in contributing your work to slurmutils, take a look at our contributing guidelines for further details.

🤝 Project and community

slurmutils is a project of the Ubuntu High-Performance Computing community. Interested in contributing bug fixes, new editors, documentation, or feedback? Want to join the Ubuntu HPC community? You’ve come to the right place 🤩

Here’s some links to help you get started with joining the community:

📋 License

slurmutils is free software, distributed under the GNU Lesser General Public License, v3.0. See the LGPL-3.0 LICENSE file for further details.

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

slurmutils-1.2.0.tar.gz (74.5 kB view details)

Uploaded Source

Built Distribution

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

slurmutils-1.2.0-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file slurmutils-1.2.0.tar.gz.

File metadata

  • Download URL: slurmutils-1.2.0.tar.gz
  • Upload date:
  • Size: 74.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for slurmutils-1.2.0.tar.gz
Algorithm Hash digest
SHA256 0b694b7ab409675a2097f7d6741c8d3a973848155c24fd653b5eafad3b079940
MD5 b70d81bfd732c3d5cf90f44e01a2bc84
BLAKE2b-256 d5c8ce40c9eb13fea5a79ffbe821a446ea0c3c3a493ffa4202aa8e48bc32c8e4

See more details on using hashes here.

File details

Details for the file slurmutils-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: slurmutils-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for slurmutils-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 859daf44d2dc2add43304e23c4dca6b29fa044d7be807d8d8c2f396abd5d3551
MD5 b3caf17f5d69e990ca883584fd4e51b7
BLAKE2b-256 653b6d284f24d286baec2f6a2b31e1a33113514bb624f11637b11e67c64815e9

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