Convert Python scripts into JobArgBase classes for HPC/Slurm job scheduling. Use this skill whenever the user wants to convert a Python script to a job_helper.JobArgBase class, generate a project config YAML/JSON/TOML for cluster submission, or structure arguments for Slurm/HPC workflows. Also trigger when the user mentions job_helper, JobArgBase, gen_project.py, project.yaml, or HPC job scheduling. If the user pastes a Python script and asks to "convert it", "prepare it for the cluster", or "make it schedulable", use this skill.
Converts plain Python scripts into job_helper.JobArgBase classes and generates
the corresponding project config file for HPC cluster submission (e.g. Slurm).
JobArgBase classGiven a plain Python script, produce a new file (e.g. my_args.py) following this pattern:
JobArgBase with those variables as typed class attributes.run() method, replacing bare variable names with self.<name>.Before (add.py):
a = 1
b = 3
print(a + b)
After (add.py):
from job_helper import JobArgBase
class Args(JobArgBase):
a: int = 1
b: int = 3
def run(self):
print(self.a + self.b)
if __name__ == "__main__":
Args().run()
Tip: Prefer primitive types (
int,float,str,bool) for attributes — they serialize cleanly to YAML/JSON/TOML.
fireIf the class lives in add.py, the user can inspect it with:
python -m fire add Args
Expected output shows the current defaults, e.g.:
a=1 b=3
This confirms the class can be instantiated as Args(a=1, b=3).
gen_project.py)Create a gen_project.py script that:
Args classjobs dict with command, config, and job_preambleproject.yaml (or .json / .toml) config fileimport yaml
from add import Args
args = Args(a=1, b=3)
jobs = {}
job_name = "add"
jobs[job_name] = {
"command": "add.Args", # module.ClassName
"config": args.model_dump(), # serialized arguments
"job_preamble": {
"dependency": ["START"], # required key; list of job names or "START"
},
}
with open("project.yaml", "w") as yaml_file:
yaml.dump({"jobs": jobs}, yaml_file)
project.yaml