Skip to content

Commit

Permalink
Merge pull request #8 from ucb-rit/fix_parsing_sinfo
Browse files Browse the repository at this point in the history
fix `sinfo` parsing and two issues with handling reservations
  • Loading branch information
wfeinstein authored Jan 10, 2024
2 parents 0b3e5ef + d8c3a6a commit 6a0ed91
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sq.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def freeze(dest_dir, name, data):
with open(path.join(dest_dir, name), 'w') as f:
f.write(data)

def read_slurm_as_df(stdout):
def read_slurm_as_df(stdout, sep = '|'):
# The first line of the data is the column headers, the rest are job data entries
# Rows are separated by newline, columns are separated by pipe |
columns, *data = [ row.split('|') for row in stdout.strip().split('\n') ]
columns, *data = [ row.split(sep) for row in stdout.strip().split('\n') ]

# Sometimes the fields can contain the pipe symbol |
# In this case it is impossible to parse unambiguously so the row is thrown out
Expand Down Expand Up @@ -96,10 +96,11 @@ def get_assoc_df(stdout):

@load_from('sinfo')
def sinfo_cmd():
return run_cmd(['sinfo', '--format', '%all'])
return run_cmd(['sinfo', '-N', '--format', '%N,%P'])
## return run_cmd(['sinfo', '--format', '%all'])

def get_sinfo_df(stdout):
df = read_slurm_as_df(stdout)
df = read_slurm_as_df(stdout, ',')
df.columns = df.columns.str.strip()
return df

Expand Down Expand Up @@ -365,7 +366,7 @@ def check_resv_conflicts(pending_job, resv_df, sinfo_df):
non_resv_nodes = non_resv_nodes - set(resv['Nodes'])
if delta:
general_interfering_resvs.append(resv)
if len(non_resv_nodes) >= remaining_num_nodes:
if len(non_resv_nodes) < remaining_num_nodes:
interfering_resvs += general_interfering_resvs

return interfering_resvs
Expand Down Expand Up @@ -432,7 +433,7 @@ def inner(pending_job):
f"This job is requesting: {job_resources_requested}",
suggest_other_qos(slurm_info, pending_job)
])
if pending_job['REASON'] in ['Priority', 'Resources']:
if pending_job['REASON'] in ['Priority', 'Resources'] or re.match("^ReqNodeNotAvail", pending_job['REASON']):
sprio_df = slurm_info.sprio_df()
resv_conflicts = check_resv_conflicts(pending_job, slurm_info.resv_df(), slurm_info.sinfo_df())
if resv_conflicts:
Expand Down

0 comments on commit 6a0ed91

Please sign in to comment.