def __init__()

in azure-slurm/slurmcc/cost.py [0:0]


    def __init__(self, start:str, end: str, cluster: str, cache_root: str, fmt: str=None) -> None:

        self.start = start
        self. end = end
        self.cluster = cluster
        self.sacct = shutil.which("sacct")
        if not self.sacct:
            raise RuntimeError("Could not find valid sacct binary")

        self.squeue = shutil.which("squeue")
        if not self.squeue:
            raise RuntimeError("Could not find valid squeue binary")

        self.sacctmgr = shutil.which("sacctmgr")
        if not self.sacctmgr:
            raise RuntimeError("Could not find valid sacctmgr binary")

        self.stats = Statistics()
        self.cache = f"{cache_root}/slurm"
        try:
            os.makedirs(self.cache, 0o777, exist_ok=True)
        except OSError as e:
            log.error("Unable to create cache directory {self.cache}")
            log.error(e.strerror)
            raise
        default_output_fmt = "jobid,user,account,cluster,partition,ncpus,nnodes,submit,start,end,elapsedraw,state"
        default_input_fmt = default_output_fmt + ",admincomment"
        self.options = ["--allusers", "--duplicates", "--parsable2", "--allocations", "--noheader"]
        avail_format = self.get_sacct_fields()
        if fmt:
            req_fmt = fmt.split(",")
            in_fmt = default_input_fmt.split(",")
            for f in req_fmt:
                if f not in avail_format:
                    raise ValueError(f"{f} is not a valid sacct format option")
                if f not in in_fmt:
                    in_fmt.append(f)
            self.output_format = ",".join(req_fmt)
            self.input_format = ",".join(in_fmt)
        else:
            self.output_format = default_output_fmt
            self.input_format = default_input_fmt

        self.in_fmt_t = namedtuple('in_fmt_t', self.input_format)
        self.slurm_fmt_t = namedtuple('slurm_fmt_t', self.output_format)
        self.c_fmt_t = namedtuple('c_fmt_t', ['cost'])