dtu-hpc-cli 1.5.1__tar.gz → 1.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/PKG-INFO +2 -2
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/README.md +1 -1
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/__init__.py +3 -2
- dtu_hpc_cli-1.5.2/dtu_hpc_cli/jobs.py +55 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/remove.py +4 -6
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/pyproject.toml +1 -1
- dtu_hpc_cli-1.5.1/dtu_hpc_cli/jobs.py +0 -36
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/client/__init__.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/client/base.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/client/local.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/client/ssh.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/config.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/constants.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/editor.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/error.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/get_command.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/get_options.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/history.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/install.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/open_error.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/open_output.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/queues.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/resubmit.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/run.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/start_time.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/stats.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/submit.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/sync.py +0 -0
- {dtu_hpc_cli-1.5.1 → dtu_hpc_cli-1.5.2}/dtu_hpc_cli/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dtu-hpc-cli
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.2
|
|
4
4
|
Summary: CLI to make it easier to work with the HPC cluster at the Technical University of Denmark (DTU).
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Christoffer Koo Øhrstrøm
|
|
@@ -68,7 +68,7 @@ You can call it using the `dtu` command, which has the these subcommands:
|
|
|
68
68
|
* **get-options**: Print options from a previously submitted job.
|
|
69
69
|
* **history**: Shows a list of the jobs that you have submitted and the options/commands that you used.
|
|
70
70
|
* **install**: Calls the installation commands in your configuration. NB. this command will install your project on the HPC - not on your local machine.
|
|
71
|
-
* **jobs**: Shows a list of running and pending jobs. It calls `
|
|
71
|
+
* **jobs**: Shows a list of running and pending jobs. It calls `bjobs` on the HPC.
|
|
72
72
|
* **open-error**: Show the error log of a given job ID in your default text editor.
|
|
73
73
|
* **open-output**: Show the output log of a given job ID in your default text editor.
|
|
74
74
|
* **queues**: List all queues or show job statistics for a single queue. It calls `bqueues` or `classtat` on the HPC.
|
|
@@ -45,7 +45,7 @@ You can call it using the `dtu` command, which has the these subcommands:
|
|
|
45
45
|
* **get-options**: Print options from a previously submitted job.
|
|
46
46
|
* **history**: Shows a list of the jobs that you have submitted and the options/commands that you used.
|
|
47
47
|
* **install**: Calls the installation commands in your configuration. NB. this command will install your project on the HPC - not on your local machine.
|
|
48
|
-
* **jobs**: Shows a list of running and pending jobs. It calls `
|
|
48
|
+
* **jobs**: Shows a list of running and pending jobs. It calls `bjobs` on the HPC.
|
|
49
49
|
* **open-error**: Show the error log of a given job ID in your default text editor.
|
|
50
50
|
* **open-output**: Show the output log of a given job ID in your default text editor.
|
|
51
51
|
* **queues**: List all queues or show job statistics for a single queue. It calls `bqueues` or `classtat` on the HPC.
|
|
@@ -34,7 +34,7 @@ from dtu_hpc_cli.types import Duration
|
|
|
34
34
|
from dtu_hpc_cli.types import Memory
|
|
35
35
|
from dtu_hpc_cli.types import Time
|
|
36
36
|
|
|
37
|
-
__version__ = "1.5.
|
|
37
|
+
__version__ = "1.5.2"
|
|
38
38
|
|
|
39
39
|
cli = typer.Typer(pretty_exceptions_show_locals=False)
|
|
40
40
|
|
|
@@ -234,9 +234,10 @@ def jobs(
|
|
|
234
234
|
node: str | None = None,
|
|
235
235
|
queue: str | None = None,
|
|
236
236
|
stats: Annotated[JobsStats, typer.Option()] = None,
|
|
237
|
+
full_name: Annotated[bool, typer.Option(help="Show the full job name instead of a truncated one.")] = True,
|
|
237
238
|
):
|
|
238
239
|
"""List running and pending jobs."""
|
|
239
|
-
list_config = JobsConfig(node=node, queue=queue, stats=stats)
|
|
240
|
+
list_config = JobsConfig(node=node, queue=queue, stats=stats, full_name=full_name)
|
|
240
241
|
execute_jobs(list_config)
|
|
241
242
|
|
|
242
243
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
import enum
|
|
3
|
+
|
|
4
|
+
from dtu_hpc_cli.client import get_client
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class JobsStats(enum.StrEnum):
|
|
8
|
+
cpu = "cpu"
|
|
9
|
+
memory = "memory"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclasses.dataclass
|
|
13
|
+
class JobsConfig:
|
|
14
|
+
node: str | None
|
|
15
|
+
queue: str | None
|
|
16
|
+
stats: JobsStats | None
|
|
17
|
+
full_name: bool = True
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
CPU_FIELDS = ["cpu_used", "run_time", "nexec_host", "slots"]
|
|
21
|
+
MEMORY_FIELDS = ["mem", "max_mem", "avg_mem", "memlimit"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def execute_jobs(config: JobsConfig):
|
|
25
|
+
command = ["bjobs"]
|
|
26
|
+
|
|
27
|
+
# In -o format, a bare field name has unlimited width while "field:" uses the recommended (truncated) width.
|
|
28
|
+
job_name_field = "job_name" if config.full_name else "job_name:"
|
|
29
|
+
base_fields = ["jobid", job_name_field, "stat", "queue", "exec_host"]
|
|
30
|
+
|
|
31
|
+
match config.stats:
|
|
32
|
+
case JobsStats.cpu:
|
|
33
|
+
fields = base_fields + CPU_FIELDS
|
|
34
|
+
case JobsStats.memory:
|
|
35
|
+
fields = base_fields + MEMORY_FIELDS
|
|
36
|
+
case _:
|
|
37
|
+
fields = None
|
|
38
|
+
|
|
39
|
+
if fields is not None:
|
|
40
|
+
# Single quotes because the SSH client wraps the command in double quotes.
|
|
41
|
+
command.extend(["-o", f"'{' '.join(fields)}'"])
|
|
42
|
+
elif config.full_name:
|
|
43
|
+
# Wide format prevents bjobs from truncating the job name (and other fields) in the default output.
|
|
44
|
+
command.append("-w")
|
|
45
|
+
|
|
46
|
+
if config.node is not None:
|
|
47
|
+
command.extend(["-m", config.node])
|
|
48
|
+
|
|
49
|
+
if config.queue is not None:
|
|
50
|
+
command.extend(["-q", config.queue])
|
|
51
|
+
|
|
52
|
+
command = " ".join(command)
|
|
53
|
+
|
|
54
|
+
with get_client() as client:
|
|
55
|
+
client.run(command)
|
|
@@ -57,12 +57,10 @@ def expand_job_ids(config: RemoveConfig) -> list[str]:
|
|
|
57
57
|
|
|
58
58
|
def get_all_job_ids() -> list[str]:
|
|
59
59
|
with get_client() as client:
|
|
60
|
-
_, output = client.run("
|
|
60
|
+
_, output = client.run("bjobs -noheader -o jobid", silent=True)
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
job_ids = [line.split()[0] for line in lines[1:] if len(line.strip()) > 0]
|
|
62
|
+
# bjobs prints "No unfinished job found" (possibly merged into stdout) when there are no jobs,
|
|
63
|
+
# so only keep lines that are actual job IDs.
|
|
64
|
+
job_ids = [line.strip() for line in output.splitlines() if line.strip().isdigit()]
|
|
67
65
|
|
|
68
66
|
return job_ids
|
|
@@ -5,10 +5,10 @@ license = "MIT"
|
|
|
5
5
|
name = "dtu-hpc-cli"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "https://github.com/ChrisFugl/DTU-HPC-CLI"
|
|
8
|
-
version = "1.5.1"
|
|
9
8
|
|
|
10
9
|
[project]
|
|
11
10
|
name = "dtu-hpc-cli"
|
|
11
|
+
version = "1.5.2"
|
|
12
12
|
|
|
13
13
|
[project.urls]
|
|
14
14
|
Changelog = "https://github.com/ChrisFugl/DTU-HPC-CLI/CHANGELOG.md"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import dataclasses
|
|
2
|
-
import enum
|
|
3
|
-
|
|
4
|
-
from dtu_hpc_cli.client import get_client
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class JobsStats(enum.StrEnum):
|
|
8
|
-
cpu = "cpu"
|
|
9
|
-
memory = "memory"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@dataclasses.dataclass
|
|
13
|
-
class JobsConfig:
|
|
14
|
-
node: str | None
|
|
15
|
-
queue: str | None
|
|
16
|
-
stats: JobsStats | None
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def execute_jobs(config: JobsConfig):
|
|
20
|
-
command = ["bstat"]
|
|
21
|
-
match config.stats:
|
|
22
|
-
case JobsStats.cpu:
|
|
23
|
-
command.append("-C")
|
|
24
|
-
case JobsStats.memory:
|
|
25
|
-
command.append("-M")
|
|
26
|
-
|
|
27
|
-
if config.node is not None:
|
|
28
|
-
command.extend(["-n", config.node])
|
|
29
|
-
|
|
30
|
-
if config.queue is not None:
|
|
31
|
-
command.extend(["-q", config.queue])
|
|
32
|
-
|
|
33
|
-
command = " ".join(command)
|
|
34
|
-
|
|
35
|
-
with get_client() as client:
|
|
36
|
-
client.run(command)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|