Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Aug 22, 2023
1 parent 4e3487b commit 4dcbc6a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pysqa/wrapper/lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

import pandas

from pysqa.wrapper.generic import SchedulerCommands

__author__ = "Jan Janssen"
Expand Down Expand Up @@ -32,3 +34,27 @@ def get_queue_status_command(self):
@staticmethod
def get_job_id_from_output(queue_submit_output):
return int(queue_submit_output.split("<")[1].split(">")[0])

@staticmethod
def convert_queue_status(queue_status_output):
job_id_lst, user_lst, status_lst, job_name_lst = [], [], [], []
line_split_lst = queue_status_output.split("\n")
if len(line_split_lst) > 1:
for l in line_split_lst[1:]:
line_segments = l.split()
if len(line_segments) > 1:
job_id_lst.append(int(line_segments[0]))
user_lst.append(line_segments[1])
status_lst.append(line_segments[2])
job_name_lst.append(line_segments[6])
df = pandas.DataFrame(
{
"jobid": job_id_lst,
"user": user_lst,
"jobname": job_name_lst,
"status": status_lst,
}
)
df.loc[df.status == "RUN", "status"] = "running"
df.loc[df.status == "PEND", "status"] = "pending"
return df

0 comments on commit 4dcbc6a

Please sign in to comment.