Skip to content

Commit

Permalink
Update README and refract
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenhanQian committed Nov 20, 2024
1 parent dd92400 commit 1c1ba99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# SlurmUI
Simple terminal UI for slurm. Credit to [Norman Müller](https://github.com/SirWyver/slurmui).

Enhanced terminal UI for slurm. Derived from [SlurmUI](https://github.com/SirWyver/slurmui).

- Job management
- GPU monitor
- Log monitor

<div align="center">
<img src="demo.png">
</div>


## Install
```shell
pip install git+https://github.com/ShenhanQian/slurmui.git
Expand Down
Binary file modified demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 21 additions & 21 deletions slurmui/slurmui.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def wrapper(*args, **kwargs):
class SlurmUI(App):
cluster = None
STAGE = {
"action": "monitor",
"monitor": {
"action": "job",
"job": {
"sort_column": 0,
"sort_ascending": True
},
Expand Down Expand Up @@ -75,23 +75,23 @@ def on_mount(self):

def on_ready(self) -> None:
self.init_gpu_table()
self.switch_table_display("monitor")
self.switch_table_display("job")
self.init_squeue_table()

def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | None:
"""Check if an action may run."""
# self.info_log.write(f"Action: {action}")
if action == "sort" and self.STAGE['action'] == 'log':
return False
elif action == "copy_jobid" and self.STAGE['action'] != 'monitor':
elif action == "copy_jobid" and self.STAGE['action'] != 'job':
return False
elif action == "delete" and self.STAGE['action'] != 'monitor':
elif action == "delete" and self.STAGE['action'] != 'job':
return False
elif action == "display_gpu" and self.STAGE['action'] != 'monitor':
elif action == "display_gpu" and self.STAGE['action'] != 'job':
return False
elif action == "display_log" and self.STAGE['action'] != 'monitor':
elif action == "display_log" and self.STAGE['action'] != 'job':
return False
elif action == "copy_log_path" and self.STAGE['action'] != 'monitor':
elif action == "copy_log_path" and self.STAGE['action'] != 'job':
return False
return True

Expand All @@ -100,7 +100,7 @@ def auto_refresh(self):

@run_in_thread
def action_refresh(self):
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
try:
self.update_squeue_table()
except Exception as e:
Expand All @@ -121,16 +121,16 @@ def action_sort(self):
else:
self.STAGE[self.STAGE["action"]]["sort_ascending"] = not self.STAGE[self.STAGE["action"]].get("sort_ascending", True)
self.STAGE[self.STAGE["action"]]['sort_column'] = sort_column
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
self.update_squeue_table()
self.switch_table_display("monitor")
self.switch_table_display("job")
elif self.STAGE["action"] == "gpu":
self.update_gpu_table()
self.switch_table_display("gpu")
self.active_table.cursor_coordinate = (0, sort_column)

def action_copy_jobid(self):
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
try:
job_id, _ = self._get_selected_job()

Expand All @@ -144,7 +144,7 @@ def action_copy_jobid(self):
self.info_log.write(str(e))

def action_delete(self):
if self.STAGE['action'] == "monitor":
if self.STAGE['action'] == "job":
try:
job_id, job_name = self._get_selected_job()
# self.info_log.clear()
Expand All @@ -155,7 +155,7 @@ def action_delete(self):
self.info_log.write(str(e))

def action_confirm(self):
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
pass
else:
# self.info_log.clear()
Expand All @@ -164,10 +164,10 @@ def action_confirm(self):
perform_scancel(self.STAGE['job_id'])
self.info_log.write(f"Delete: {self.STAGE['job_id']}? succeeded")
self.update_squeue_table()
self.STAGE["action"] = "monitor"
self.STAGE["action"] = "job"

def action_abort_quit(self):
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
self.exit(0)
else:
self.action_abort()
Expand All @@ -179,9 +179,9 @@ def action_abort(self):
if self.STAGE["action"] == "log":
self._minimize_joblog_panel()

self.STAGE['action'] = "monitor"
self.STAGE['action'] = "job"
self.update_squeue_table()
self.switch_table_display("monitor")
self.switch_table_display("job")
# self.info_log.clear()

def action_display_gpu(self):
Expand All @@ -195,7 +195,7 @@ def action_display_gpu(self):

def action_display_log(self):
try:
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
job_id, job_name = self._get_selected_job()
self.STAGE.update({"action": "log", "job_id": job_id, "job_name": job_name})
self._maximize_joblog_panel()
Expand All @@ -205,7 +205,7 @@ def action_display_log(self):
self.info_log.write(str(e))

def action_copy_log_path(self):
if self.STAGE["action"] == "monitor":
if self.STAGE["action"] == "job":
try:
job_id, _ = self._get_selected_job()
log_fn = get_log_fn(job_id)
Expand Down Expand Up @@ -415,7 +415,7 @@ def switch_table_display(self, action):
self.gpu_table.styles.height = "100%"
self.squeue_table.styles.height = "0%"
self.active_table = self.gpu_table
elif action == "monitor":
elif action == "job":
self.gpu_table.styles.height = "0%"
self.squeue_table.styles.height = "80%"
self.active_table = self.squeue_table
Expand Down

0 comments on commit 1c1ba99

Please sign in to comment.