PySlurm / pyslurm

Python Interface to Slurm
https://pyslurm.github.io
GNU General Public License v2.0
483 stars 118 forks source link

feature request: add alloc_mem to pyslurm.node() #51

Closed giovtorres closed 8 years ago

giovtorres commented 8 years ago

pyslurm.node().get() doesn't give allocated memory for any nodes. I'm looking for this value:

scontrol show node cn0001 | grep AllocMem
   OS=Linux RealMemory=124926 AllocMem=90112 Sockets=2 Boards=1

pyslurm does report real_memory for each node.

Thanks, Giovanni

gingergeeks commented 8 years ago

Giovanni, OK, I will take a look at the API structure and see what I'm missing to call. Which version are you using ?

Regards, Mark

giovtorres commented 8 years ago

pyslurm-14.11.5 slurm 14.11.9 (going to 15.08 soon)

gingergeeks commented 8 years ago

Thanks, looks like I will need to call out to the opaque data structure via select_nodeinfo. Most of the code is there but not complete or tested for some time. As I'm working on slurm-14.11.x for other people I will look to adding it in to that branch first and then 15.x later.

giovtorres commented 8 years ago

Great! Thanks. I can help test that portion of the code as well.

gingergeeks commented 8 years ago

It is now coded up but I will need to test it tonight/tomorrow before I push some code to you and then I will upload the changes to git.

gingergeeks commented 8 years ago

OK, here we go. I believe It appears to work.......which is nice ! Of course I was banging my head on the desk as I was still getting zero until I realised that I needed to turn on "SelectTypeParameters=CR_CORE_MEMORY" in the config......dooh.

Please find attached a zipped replacement pyslurm.pyx for you. Obviously you will need to replace the existing one and do a build/install etc.

pyslurm.pyx.zip

giovtorres commented 8 years ago

Looks good! Just need to remove the print statement on line 2385.

gingergeeks commented 8 years ago

Cool, I will remove the debug line as well.

gingergeeks commented 8 years ago

Giovanni, If you pull the latest 14.11.5 the changes as discussed previously have been committed. Please let me know if this now works and close the ticket if you are happy. I will look at the license gres handling now !

Mark

giovtorres commented 8 years ago

I pulled the latest 14.11.5 and rebuilt. alloc_memory is now not showing up for any nodes.

>>> pprint(nodes.get("cn0001").get("alloc_memory"))
None

Here's the diff between the latest 14.11.5 and yesterday's out-of-band patch:

$ diff 14.11.5/pyslurm/pyslurm.pyx patch/pyslurm/pyslurm.pyx

2148a2148,2149
>       self.get()
> 
2278c2279
<           int i, total_used, cpus_per_node, rc
---
>           int i, total_used, cpus_per_node, rc, alloc_mem
2281c2282
<           uint32_t my_state, alloc_mem
---
>           uint32_t my_state
2298,2300d2298
<           if self._record.name is NULL:
<               break
< 
2302c2300,2301
<           alloc_mem = alloc_cpus = err_cpus = 0
---
>           alloc_cpus = err_cpus = 0
>           alloc_mem = 0
2406c2405
<           Host_dict['err_cpus'] = err_cpus
---
>           Host_dict['alloc_memory'] = alloc_mem
2407a2407
>           Host_dict['err_cpus'] = err_cpus
gingergeeks commented 8 years ago

Yep, too much haste ! Have committed missing host dictionary entry, please try again

giovtorres commented 8 years ago

Yup, looks good. Thanks Mark!