jean-zay-users/jean-zay-doc

Snippet to get number of pending and running jobs

lesteve opened this issue · 1 comments

import subprocess
import io
import shlex

import pandas as pd

squeue_command = shlex.split('squeue -p gpu_p13 -o "%i;%P;%j;%u;%T;%M;%l;%D;%R"')
squeue_output = subprocess.check_output(squeue_command).decode()

df = pd.read_csv(io.StringIO(squeue_output), sep=";")

for state in ("RUNNING", "PENDING"):
    print(state)
    print(
        df[df["STATE"] == state]
        .groupby("USER")["NODES"]
        .sum()
        .sort_values(ascending=False)
        .head(15)
    )

This can be useful to get an overall idea of the state of running and pending jobs. In particular this can be used to figure out whether some users have a lot of jobs pending/running and whether they tend to be very often the same users.