PySlurm / pyslurm

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

Brought __rpc_num2string in sync with slurm 21.08 message types #259

Closed wresch closed 1 year ago

wresch commented 1 year ago

I've encountered KeyErrors for key 5039 when gathering statistics with pyslurm.statistics().get(). This was the result of a new message type (REQUEST_AUTH_TOKEN = 5039) being introduced. That prompted me to go over the whole dict mapping slurm message types to names. Instead of doing this manually i created a small c program that spits out the slurm_msg_type_t enum with numeric values and symbolic names. I used that output to update pyslurm.pyx. Note that the slurm header file contains some symbolic names for defunct message types that don't line up with their numeric value.

In addition i also added code to handle KeyError during statistic gathering.

__rpc_num2string appears to only be used during statistics gathering.

Note: I only did this for the 21.08 branch based of the message types defined for slurm 21.08. I'm not sure what version i would target for the master branch

tazend commented 1 year ago

Hi @wresch

thanks for the contribution and for bringing the RPC types uptodate. In the C-script it says you autogenerated the printf statements, right? Instead of integrating the c-script specifically for 21.08, could you perhaps create a small script with the code you used to autogenerate the print-statements from the enum?

With a generic script I think we can more easily translate any enum to a dict in future versions (for example when RPC types are changed again in a major slurm update)

What do you think about that?

wresch commented 1 year ago

that is a much better idea. I'll update the PR in a bit

tazend commented 1 year ago

Hi,

looks great! I'll go ahead and merge it. If you want to, you can also make a PR for the master branch. The master is on version 22.05.