charmed-hpc / slurmutils

Utilities and APIs for interfacing with the Slurm workload manager ⚙️🔌
GNU Lesser General Public License v3.0
1 stars 3 forks source link

[Enhancement]: Add support for creating Slurm configuration from dictionary #14

Closed NucciTheBoss closed 2 months ago

NucciTheBoss commented 2 months ago

By adding a from_dict method, it makes it much easier to work with Slurm configuration information as configuration objects do not need to be constructed manually. The from_dict() constructor can take in data passed in from a Juju integration in bulk and make quick changes to the relevant configuration file.

The alternative constructor should function like the following:

from slurmutils.models import Node

node = Node.from_dict(
    {
        "NodeName": "batch-[0-25]", 
        "NodeAddr": "12.34.56.78", 
        "CPUs": 1, 
        "RealMemory": 1000, 
        "TmpDisk": 10000,
    }
)
print(node.node_name)
NucciTheBoss commented 2 months ago

Related to discussion https://github.com/orgs/charmed-hpc/discussions/5