Skip to content

Commit c567b1a

Browse files
committed
Add scancel
1 parent ae8afe2 commit c567b1a

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
[![Downloads](https://pepy.tech/badge/sumsjob)](https://pepy.tech/project/sumsjob)
55
[![License](https://img.shields.io/github/license/lululxvi/sumsjob)](https://github.com/lululxvi/sumsjob/blob/master/LICENSE)
66

7-
&Sigma;&Sigma;<sub>Job</sub> or Sums<sub>Job</sub> (**S**imple **U**tility for **M**ultiple-**S**ervers **Job** **Sub**mission) is a simple Linux command-line utility which submits a job to one of the multiple servers each with limited resources such as GPUs. &Sigma;&Sigma;<sub>Job</sub> provides similar key functions for multiple servers as [Slurm Workload Manager](https://slurm.schedmd.com) for supercomputers and computer clusters. It provides four key functions:
7+
&Sigma;&Sigma;<sub>Job</sub> or Sums<sub>Job</sub> (**S**imple **U**tility for **M**ultiple-**S**ervers **Job** **Sub**mission) is a simple Linux command-line utility which submits a job to one of the multiple servers each with limited resources such as GPUs. &Sigma;&Sigma;<sub>Job</sub> provides similar key functions for multiple servers as [Slurm Workload Manager](https://slurm.schedmd.com) for supercomputers and computer clusters. It provides the following key functions:
88

99
- show the status of GPUs on all servers,
1010
- submit a job to servers in noninteractive mode, i.e., the job will be running in the background of the server,
1111
- submit a job to servers in interactive mode, just as the job is running in your local machine,
12-
- display all running jobs.
12+
- display all running jobs,
13+
- cancel running jobs.
1314

1415
## Motivation
1516

@@ -83,6 +84,12 @@ Display all running jobs ordered by the start time. For example,
8384

8485
![](https://github.com/lululxvi/sumsjob/blob/master/docs/figs/sacct.png)
8586

87+
### `$ scancel jobname`
88+
89+
Cancel a running job.
90+
91+
- `jobname` : Job name.
92+
8693
## Installation
8794

8895
Install Sums<sub>Job</sub> with `pip`:

sumsjob/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
__all__ = ["gpuresource", "sacct", "submit"]
1+
__all__ = ["gpuresource", "sacct", "scancel", "submit"]
22

33
from .__about__ import __version__
44

55
from . import gpuresource
66
from . import sacct
7+
from . import scancel
78
from . import submit

sumsjob/cancel.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

sumsjob/scancel.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
__al__ = ["scancel"]
2+
3+
import argparse
4+
import subprocess
5+
6+
from .sacct import sacct
7+
from .utils import local_cmdline
8+
9+
10+
def scancel(jobname):
11+
jobs = sacct()
12+
for job in jobs:
13+
if job["JobName"] == jobname:
14+
cmd = f"screen -S sumsjob-{jobname} -X quit"
15+
cmd = local_cmdline(job["Server"], cmd, verbose=0)
16+
subprocess.run(cmd, shell=True, check=True)
17+
print(f"Job {jobname} on {job['Server']} cancelled.")
18+
return
19+
print(f"Job {jobname} not found.")
20+
21+
22+
def main():
23+
parser = argparse.ArgumentParser(description="Cancel a running job.")
24+
parser.add_argument("jobname", help="Job name")
25+
args = parser.parse_args()
26+
27+
scancel(args.jobname)
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)