Skip to content

Commit ff3dc42

Browse files
authored
Add slurmctld functions and full slurm.conf access (#367)
Further changes: * move cpu_freq_int_to_str to utils.helpers * cstr: add configurable delim to to_list * update partition unit tests * tests: integration tests for slurmctld * partition: use _get_memory from slurmctld module * mkdocs.yml: add pymdownx.magiclink * docs: add griffe_exts.py script for prettier docs This allows to dynamically link to the Slurm Documentation with different Slurm versions. For example it will replace this in the docstring: {slurm.conf#OPT_MpiParams} with this in the finally rendered docs, when we are on pyslurm 24.11.x: https://slurm.schedmd.com/archive/slurm-24.11-latest/slurm.conf.html#OPT_MpiParams This way we can dynamically link to the Slurm docs. * docs: add slurmctld reference API page * docs: remove old config class documentation * update common tests * remove the setup.py clean step from builddocs.sh
1 parent 5d8f1cf commit ff3dc42

27 files changed

+3511
-174
lines changed

docs/reference/config.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/reference/slurmctld.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: slurmctld
3+
---
4+
5+
::: pyslurm.slurmctld
6+
handler: python
7+
options:
8+
members: yes

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ plugins:
6060
show_root_heading: true
6161
show_symbol_type_toc: true
6262
show_symbol_type_heading: true
63+
extensions:
64+
- scripts/griffe_exts.py:DynamicDocstrings
6365

6466
markdown_extensions:
6567
- admonition
@@ -73,6 +75,7 @@ markdown_extensions:
7375
- pymdownx.inlinehilite
7476
- pymdownx.superfences
7577
- pymdownx.details
78+
- pymdownx.magiclink
7679

7780
extra:
7881
version:

pyslurm/core/job/job.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ from pyslurm.utils.helpers import (
5050
_getpwall_to_dict,
5151
instance_to_dict,
5252
_get_exit_code,
53+
cpu_freq_int_to_str,
5354
)
5455

5556

pyslurm/core/job/step.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ from pyslurm.utils.helpers import (
3434
uid_to_name,
3535
humanize_step_id,
3636
dehumanize_step_id,
37+
cpu_freq_int_to_str,
3738
)
38-
from pyslurm.core.job.util import cpu_freq_int_to_str
3939
from pyslurm.utils.ctime import (
4040
secs_to_timestr,
4141
mins_to_timestr,

pyslurm/core/job/util.pyx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -246,37 +246,6 @@ def cpu_freq_str_to_int(freq):
246246
raise ValueError(f"Invalid cpu freq value: {freq}.")
247247

248248

249-
def cpu_freq_int_to_str(freq):
250-
"""Convert a numerical cpufreq value to its string representation."""
251-
if freq == slurm.CPU_FREQ_LOW:
252-
return "LOW"
253-
elif freq == slurm.CPU_FREQ_MEDIUM:
254-
return "MEDIUM"
255-
elif freq == slurm.CPU_FREQ_HIGHM1:
256-
return "HIGHM1"
257-
elif freq == slurm.CPU_FREQ_HIGH:
258-
return "HIGH"
259-
elif freq == slurm.CPU_FREQ_CONSERVATIVE:
260-
return "CONSERVATIVE"
261-
elif freq == slurm.CPU_FREQ_PERFORMANCE:
262-
return "PERFORMANCE"
263-
elif freq == slurm.CPU_FREQ_POWERSAVE:
264-
return "POWERSAVE"
265-
elif freq == slurm.CPU_FREQ_USERSPACE:
266-
return "USERSPACE"
267-
elif freq == slurm.CPU_FREQ_ONDEMAND:
268-
return "ONDEMAND"
269-
elif freq == slurm.CPU_FREQ_SCHEDUTIL:
270-
return "SCHEDUTIL"
271-
elif freq & slurm.CPU_FREQ_RANGE_FLAG:
272-
return None
273-
elif freq == slurm.NO_VAL or freq == 0:
274-
return None
275-
else:
276-
# This is in kHz
277-
return freq
278-
279-
280249
def dependency_str_to_dict(dep):
281250
if not dep:
282251
return None

pyslurm/core/partition.pyx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# partition.pyx - interface to work with partitions in slurm
33
#########################################################################
44
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
5-
# Copyright (C) 2023 PySlurm Developers
5+
# Copyright (C) 2025 PySlurm Developers
66
#
77
# This file is part of PySlurm
88
#
@@ -31,6 +31,7 @@ from pyslurm.core.error import RPCError, verify_rpc
3131
from pyslurm.utils.ctime import timestamp_to_date, _raw_time
3232
from pyslurm.constants import UNLIMITED
3333
from pyslurm.settings import LOCAL_CLUSTER
34+
from pyslurm.core.slurmctld.config import _get_memory
3435
from pyslurm import xcollections
3536
from pyslurm.utils.helpers import (
3637
uid_to_name,
@@ -832,21 +833,3 @@ cdef _concat_job_default_str(typ, val, char **job_defaults_str):
832833
current.update({typ : _val})
833834

834835
cstr.from_dict(job_defaults_str, current)
835-
836-
837-
def _get_memory(value, per_cpu):
838-
if value != slurm.NO_VAL64:
839-
if value & slurm.MEM_PER_CPU and per_cpu:
840-
if value == slurm.MEM_PER_CPU:
841-
return UNLIMITED
842-
return u64_parse(value & (~slurm.MEM_PER_CPU))
843-
844-
# For these values, Slurm interprets 0 as being equal to
845-
# INFINITE/UNLIMITED
846-
elif value == 0 and not per_cpu:
847-
return UNLIMITED
848-
849-
elif not value & slurm.MEM_PER_CPU and not per_cpu:
850-
return u64_parse(value)
851-
852-
return None

pyslurm/core/slurmctld.pyx

Lines changed: 0 additions & 62 deletions
This file was deleted.

pyslurm/core/slurmctld/__init__.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# cython: c_string_type=unicode, c_string_encoding=default
2+
# cython: language_level=3
3+
4+
from .config cimport Config

pyslurm/core/slurmctld/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from .config import (
2+
Config,
3+
MPIConfig,
4+
AccountingGatherConfig,
5+
CgroupConfig,
6+
)
7+
from .enums import ShutdownMode
8+
from .base import (
9+
PingResponse,
10+
ping,
11+
ping_primary,
12+
ping_backup,
13+
ping_all,
14+
shutdown,
15+
reconfigure,
16+
takeover,
17+
add_debug_flags,
18+
remove_debug_flags,
19+
clear_debug_flags,
20+
get_debug_flags,
21+
set_log_level,
22+
get_log_level,
23+
enable_scheduler_logging,
24+
is_scheduler_logging_enabled,
25+
set_fair_share_dampening_factor,
26+
get_fair_share_dampening_factor,
27+
)

0 commit comments

Comments
 (0)