Explicit model for task resources
The management of task resources in iota2step is brittle. We have units as strings, values which can be ints, floats and strings. Also, the use of dictionaries does not make a lot of sense here, since there won't be any fields added at runtime. Therefore, dataclasses or named tuples should be preferred.
I propose to refactor the code with something like this:
from enum import auto
class RamUnit(auto):
mb
gb
@dataclass
class Ram:
amount: int
unit: RamUnit
@dataclass
class HardwareLimits:
ram: Ram
cpu: int
gpu: int
@dataclass
class WallTime:
hours: int
minutes: int
def str():
return f"{self.hours:02}:{self.minutes:02}:00"
@dataclass
class TaskResources:
hardware_limits: HardwareLimits
queue: str
walltime: WallTime