Using sacctmgr to get max cores and max mem for an account

I want to use the resources reported by sacctmgr for a selected account in the form.yml.erb as max values in other form variables. I am using :

sacctmgr -n -p show account withassoc where parent=root format=grptres where account=“#{account}”

to get that information but I think the account form variable is empty when the code is evaluated and I get a zero for max memory in my form. I am creating an array at the top of the form for all of the accounts that a $USER has. Should I be creating another array with the max cores and and max memory for each account they are associated with? If so how would I access those values when the account form value changes so that I can set the max: max_mem on the memory amount form variable?

auto_accounts could work for you, up to a point. It’s dynamic WRT to clusters and qos (I think we’re lacking queues?), but won’t set min and max cpus.

If it were me - I would use auto_accounts to populate accounts then use data-min and data-max attributes to set mins and maxes.

Lastly - if you have to write Ruby to do query Slurm you should write it in an initializer because those form.yml.erb files are rendered a lot (I mean they’re read & rendered even without hitting that specific page) so embedding too much ruby (or ruby that queries other systems) is going to cause issues for your site.

Thanks. We use a cache for those queries so it would evaluate it once in a 12 hour period. I do already get an array of the accounts. I’ll take a look at the docs to see if I can do it with the dynamic min and max but I think I’ll run into the same issue.

The auto_accounts got me a list of the partitions on the cluster but not the accounts I belong to. I’ll keep working on it.

I was able to do this using an associative array in ruby using the slurm account name and the max limits I needed then used the data-max-variable: value to set the max value. I’m going to try to put this in as an initializer next.