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

feat: meld LineInterface into BaseModel #20

Closed NucciTheBoss closed 1 day ago

NucciTheBoss commented 2 days ago

This PR refactors how the models are parsed and marshalled to and from their respective configuration file formats (string) into a data model that Python can understand.

The TL;DR is that now, if you want a data model in its configuration file format, all you have to do is just call str:

str(some_slurm_data_model)

If you want to construct a data model from a string, you can use the alternative constructor from_str:

SlurmConfig.from_str("<slurm configuration data>")

This removes the need for the intermediary _parse and _marshall functions that were defined as part of each editor.

NucciTheBoss commented 1 day ago

Really liking the new structure! I think it's a lot better to have the parsing methods available directly on the models, since it could enable interesting abstractions around that.

I agree with that! It'll be nice to have a similar API to the json and yaml modules with the load, loads, dump, and dumps methods, but also still be able to enable developers to write their own abstractions around the Slurm data models.

NucciTheBoss commented 1 day ago

Going to open follow up PR with the vbump and updates to the README