Skip to content

Commit 6c7c163

Browse files
committed
slurm cpus per node = cores per socket * threads per core * sockets per node
1 parent b31c964 commit 6c7c163

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/hpc_connect/command/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main(argv: list[str] | None = None) -> int:
7373
module = _commands[args.command]
7474
cfg = Config()
7575
cfg.set_main_options(args)
76-
module.execute(cfg, args)
76+
module.execute(cfg, args) # ty: ignore[unresolved-attribute]
7777
return 0
7878

7979

@@ -96,8 +96,8 @@ def make_parser() -> argparse.ArgumentParser:
9696

9797
def add_command(subparsers: argparse._SubParsersAction, module: ModuleType) -> None:
9898
name = module.__name__.split(".")[-1].lower()
99-
parser = subparsers.add_parser(
100-
name, add_help=getattr(module, "add_help", True), help=module.description
101-
)
102-
module.setup_parser(parser)
99+
add_help = getattr(module, "add_help", True)
100+
description = getattr(module, "description", None)
101+
parser = subparsers.add_parser(name, add_help=add_help, help=description)
102+
module.setup_parser(parser) # ty: ignore[unresolved-attribute]
103103
_commands[name] = module

src/hpc_connect/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def compute_required_resources(
493493
assert ranks is not None
494494
assert ranks_per_socket is not None
495495
nodes = int(math.ceil(ranks / ranks_per_socket / self.sockets_per_node))
496-
sockets = int(math.ceil(ranks / ranks_per_socket))
496+
sockets = int(math.ceil(ranks / ranks_per_socket)) # ty: ignore[unsupported-operator]
497497
reqd_resources["np"] = ranks
498498
reqd_resources["ranks"] = ranks
499499
reqd_resources["ranks_per_socket"] = ranks_per_socket

src/hpc_connect/submit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
import getpass
6-
import importlib
6+
import importlib.resources
77
import os
88
from abc import ABC
99
from abc import abstractmethod

src/hpc_connect/util/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5+
import json
6+
import json.decoder
57
import os
68
import re
79
import stat
@@ -46,8 +48,6 @@ def sanitize_path(path: str) -> str:
4648

4749

4850
def safe_loads(arg):
49-
import json
50-
5151
try:
5252
return json.loads(arg)
5353
except json.decoder.JSONDecodeError:

src/hpcc_slurm/submit.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def read_sinfo() -> dict[str, Any] | None:
222222
return None
223223
else:
224224
sockets_per_node: int
225-
cpus_per_socket: int
225+
cores_per_socket: int
226+
threads_per_core: int
226227
cpus_per_node: int
227228
node_count: int
228229
for line in proc.stdout.split("\n"):
@@ -232,7 +233,12 @@ def read_sinfo() -> dict[str, Any] | None:
232233
elif parts and parts[0].startswith("SOCKETS"):
233234
continue
234235
data = [safe_loads(part) for part in parts]
235-
sockets_per_node, cpus_per_socket, _, cpus_per_node, node_count, *gres = data
236+
sockets_per_node = data[0]
237+
cores_per_socket = data[1]
238+
threads_per_core = data[2]
239+
cpus_per_node = data[3]
240+
node_count = data[4]
241+
gres = data[5:]
236242
break
237243
else:
238244
raise ValueError(f"Unable to read sinfo output:\n{proc.stdout}")
@@ -248,7 +254,7 @@ def read_sinfo() -> dict[str, Any] | None:
248254
"resources": [
249255
{
250256
"type": "cpu",
251-
"count": cpus_per_socket,
257+
"count": cores_per_socket * threads_per_core,
252258
},
253259
],
254260
}

src/hpcc_subprocess/submit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
import importlib
5+
import importlib.resources
66
import logging
77
import os
88
import shutil

0 commit comments

Comments
 (0)