Skip to content

Commit d7fe3b0

Browse files
faganihajizadarezib
authored andcommitted
fix(agent): correct ClusterShell NodeSet import
The module was incorrectly imported as 'import ClusterShell' which doesn't expose NodeSet as a direct attribute. This causes AttributeError when trying to access ClusterShell.NodeSet.NodeSet(). Changed to import NodeSet directly from ClusterShell.NodeSet module and updated the usage accordingly throughout the codebase. This fixes the error when viewing jobs on a specific node in the web UI. Signed-off-by: Rémi Palancher <[email protected]>
1 parent 56330bf commit d7fe3b0

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [unreleased]
9+
10+
### Fixed
11+
- agent: Import of ClusterShell NodeSet class (#682). Contribution from
12+
@faganihajizada.
13+
814
## [6.0.0] - 2025-11-28
915

1016
### Added

slurmweb/slurmrestd/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import logging
1010

1111
import requests
12-
import ClusterShell
12+
from ClusterShell.NodeSet import NodeSet
1313

1414
from .unix import SlurmrestdUnixAdapter
1515
from .auth import SlurmrestdAuthentifier
@@ -222,7 +222,7 @@ def on_node(job):
222222
"""Return True if job is allocated this node."""
223223
if job["nodes"] == "":
224224
return False
225-
return node in ClusterShell.NodeSet.NodeSet(job["nodes"])
225+
return node in NodeSet(job["nodes"])
226226

227227
def terminated(job):
228228
"""Return True if job is terminated."""

slurmweb/tests/slurmrestd/test_slurmrestd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import urllib
1010

1111
import requests
12-
import ClusterShell
12+
from ClusterShell.NodeSet import NodeSet
1313

1414
from slurmweb.slurmrestd import Slurmrestd
1515
from slurmweb.slurmrestd.errors import (
@@ -177,7 +177,7 @@ def terminated(job):
177177
return False
178178

179179
# Select random busy node on cluster
180-
busy_nodes = ClusterShell.NodeSet.NodeSet()
180+
busy_nodes = NodeSet()
181181
for job in asset:
182182
if not terminated(job):
183183
busy_nodes.update(job["nodes"])
@@ -195,7 +195,7 @@ def terminated(job):
195195
self.assertNotIn(job["job_state"], ["COMPLETED", "FAILED", "TIMEOUT"])
196196
self.assertIn(
197197
random_busy_node,
198-
ClusterShell.NodeSet.NodeSet(job["nodes"]),
198+
NodeSet(job["nodes"]),
199199
)
200200

201201
# Test get jobs on nonexistent node.

slurmweb/tests/views/test_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from unittest import mock
99
import random
1010

11-
import ClusterShell
11+
from ClusterShell.NodeSet import NodeSet
1212

1313
from racksdb.version import get_version as racksdb_get_version
1414

@@ -191,7 +191,7 @@ def terminated(job):
191191
return False
192192

193193
# Select random busy node on cluster
194-
busy_nodes = ClusterShell.NodeSet.NodeSet()
194+
busy_nodes = NodeSet()
195195
for job in jobs_asset:
196196
if not terminated(job):
197197
busy_nodes.update(job["nodes"])
@@ -210,7 +210,7 @@ def terminated(job):
210210
self.assertNotIn(job["job_state"], ["COMPLETED", "FAILED", "TIMEOUT"])
211211
self.assertIn(
212212
random_busy_node,
213-
ClusterShell.NodeSet.NodeSet(job["nodes"]),
213+
NodeSet(job["nodes"]),
214214
)
215215

216216
@all_slurm_api_versions

0 commit comments

Comments
 (0)