Skip to content

Commit

Permalink
chore(all): update slurm_ops to 0.12 and slurmutils requirement
Browse files Browse the repository at this point in the history
to `<1.0.0,>=0.11.0`
  • Loading branch information
dsloanm committed Jan 7, 2025
1 parent 94c1ce3 commit 5575440
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 28 deletions.
2 changes: 1 addition & 1 deletion charms/slurmctld/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==2.17.1
slurmutils~=0.11.0
slurmutils<1.0.0,>=0.11.0
2 changes: 1 addition & 1 deletion charms/slurmdbd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==2.17.1
slurmutils~=0.11.0
slurmutils<1.0.0,>=0.11.0
2 changes: 1 addition & 1 deletion charms/slurmrestd/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ops==2.17.1
slurmutils~=0.11.0
slurmutils<1.0.0,>=0.11.0
83 changes: 59 additions & 24 deletions external/lib/charms/hpc_libs/v0/slurm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,20 @@ def _on_install(self, _) -> None:
import yaml
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from slurmutils.editors import acctgatherconfig, cgroupconfig, slurmconfig, slurmdbdconfig
from slurmutils.models import AcctGatherConfig, CgroupConfig, SlurmConfig, SlurmdbdConfig
from slurmutils.editors import (
acctgatherconfig,
cgroupconfig,
gresconfig,
slurmconfig,
slurmdbdconfig,
)
from slurmutils.models import (
AcctGatherConfig,
CgroupConfig,
GRESConfig,
SlurmConfig,
SlurmdbdConfig,
)

try:
import charms.operator_libs_linux.v0.apt as apt
Expand All @@ -97,14 +109,14 @@ def _on_install(self, _) -> None:

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 10
LIBPATCH = 12

# Charm library dependencies to fetch during `charmcraft pack`.
PYDEPS = [
"cryptography~=44.0.0",
"pyyaml>=6.0.2",
"python-dotenv~=1.0.1",
"slurmutils~=0.9.0",
"slurmutils<1.0.0,>=0.11.0",
"distro~=1.9.0",
]

Expand Down Expand Up @@ -245,26 +257,6 @@ def edit(self):
"""Edit the current configuration file."""


class _SlurmConfigManager(_ConfigManager):
"""Control the `slurm.conf` configuration file."""

def load(self) -> SlurmConfig:
"""Load the current `slurm.conf` configuration file."""
return slurmconfig.load(self._config_path)

def dump(self, config: SlurmConfig) -> None:
"""Dump new configuration into `slurm.conf` configuration file."""
slurmconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group)

@contextmanager
def edit(self) -> SlurmConfig:
"""Edit the current `slurm.conf` configuration file."""
with slurmconfig.edit(
self._config_path, mode=0o644, user=self._user, group=self._group
) as config:
yield config


class _AcctGatherConfigManager(_ConfigManager):
"""Manage the `acct_gather.conf` configuration file."""

Expand Down Expand Up @@ -309,6 +301,46 @@ def edit(self) -> CgroupConfig:
yield config


class _GRESConfigManager(_ConfigManager):
"""Manage the `gres.conf` configuration file."""

def load(self) -> GRESConfig:
"""Load the current `gres.conf` configuration files."""
return gresconfig.load(self._config_path)

def dump(self, config: GRESConfig) -> None:
"""Dump new configuration into `gres.conf` configuration file."""
gresconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group)

@contextmanager
def edit(self) -> GRESConfig:
"""Edit the current `gres.conf` configuration file."""
with gresconfig.edit(
self._config_path, mode=0o644, user=self._user, group=self._group
) as config:
yield config


class _SlurmConfigManager(_ConfigManager):
"""Control the `slurm.conf` configuration file."""

def load(self) -> SlurmConfig:
"""Load the current `slurm.conf` configuration file."""
return slurmconfig.load(self._config_path)

def dump(self, config: SlurmConfig) -> None:
"""Dump new configuration into `slurm.conf` configuration file."""
slurmconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group)

@contextmanager
def edit(self) -> SlurmConfig:
"""Edit the current `slurm.conf` configuration file."""
with slurmconfig.edit(
self._config_path, mode=0o644, user=self._user, group=self._group
) as config:
yield config


class _SlurmdbdConfigManager(_ConfigManager):
"""Control the `slurmdbd.conf` configuration file."""

Expand Down Expand Up @@ -951,6 +983,9 @@ def __init__(self, *args, **kwargs) -> None:
self.cgroup = _CgroupConfigManager(
self._ops_manager.etc_path / "cgroup.conf", self.user, self.group
)
self.gres = _GRESConfigManager(
self._ops_manager.etc_path / "gres.conf", self.user, self.group
)


class SlurmdManager(_SlurmManagerBase):
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cryptography~=43.0.1
distro==1.9.0
python-dotenv~=1.0.1
pycryptodome==3.20.0
slurmutils~=0.11.0
slurmutils<1.0.0,>=0.11.0
dbus-fast>=1.90.2
pyfakefs==5.7.1

Expand Down

0 comments on commit 5575440

Please sign in to comment.