Ticket 4948

Summary: squeue -o "%all" output has the field "user" twice
Product: Slurm Reporter: Tom de Geus <tom>
Component: User CommandsAssignee: Director of Support <support>
Status: RESOLVED FIXED QA Contact:
Severity: 4 - Minor Issue    
Priority: --- CC: tim
Version: 17.02.7   
Hardware: Linux   
OS: Linux   
Site: EPFL Alineos Sites: ---
Atos/Eviden Sites: --- Confidential Site: ---
Coreweave sites: --- Cray Sites: ---
DS9 clusters: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Linux Distro: ---
Machine Name: CLE Version:
Version Fixed: 18.08 Target Release: ---
DevPrio: --- Emory-Cloud Sites: ---

Description Tom de Geus 2018-03-19 11:29:26 MDT
The output of:

    squeue -o "%all"

has the field "USER" twice. Once with the user-id, once with the username.
Comment 4 Isaac Hartung 2018-03-22 14:42:54 MDT
Hi Tom,

We are aware of this--the first column labeled user holds the user_name of the job and the second column labeled user holds the user_id.  The identical label has to do with a concern for column width, so for now I would not expect a fix, but there is some discussion for version 18.08 on this matter.

I'll comment on this ticket should we decide to change, but for now I am closing it.

Regards.
Comment 5 Tom de Geus 2018-03-23 03:01:55 MDT
Hi Isaac,

Thanks for the reply.

I will just argue why I do think that the field names should be different. Note that they could be simply USER and UID if you are worried about the length.

I automatically process the output of `squeue -o "%all"` with Python (I have included a code snippet below for reference). For this I use a dictionary, which is easy and efficient to reference from, but relies of unique keys. To stay close `squeue` these keys are taken from the header. Here is the issue with repeating the same column name. This problem will surely appear in other automatic processing tools.

As promised, the code snippet:

```python
# read the command
data = subprocess.check_output('squeue -o "%all"',shell=True).decode('utf-8')

# extract the header and the info
head,data = data.split('\n',1)
data      = list(filter(None,data.split('\n')))

# convert to list of dictionaries
# - initialize
lines = []
# - loop over lines
for line in data:
  # -- initialize empty dictionary
  info = {}
  # -- fill dictionary
  for key,val in zip(head,line.split('|')):
    if len(key.strip()) > 0:
      info[key.strip()] = val.strip()
  # -- store to list of lines
  lines += [info]
``` 

P.S. I realize that one can also use the API. However, I don't think that it is currently available in Python right?
Comment 6 Isaac Hartung 2018-03-26 10:34:03 MDT
Tom,

Thank you for your input, I will include it in our next staff meeting.

Python API: There is a project called PySlurm that might interest you; however, we do not develop or support it.

Regards
Comment 9 Isaac Hartung 2018-03-27 14:38:40 MDT
Hi Tom,

The User ID header in squeue has been changed to UID in the following commit:

ac8b95e53ad2f7d7c880de1cd971eda7f5dc579e

The change will be included in 18.08.

Regards
Comment 10 Isaac Hartung 2018-03-27 14:39:45 MDT
.
Comment 11 Tom de Geus 2018-03-28 02:10:59 MDT
Great! Thanks!