util
This module contains utility functions.
- util.execCmd(cmd, file=None, mode='w')
Executes a command locally.
- Args:
cmd (str): Command to be executed. file (str, optional): Path to the output file. Defaults to None. mode (str, optional): “w” if the file should be rewritten with the output, “a” if the output should be appended to an existing file. Defaults to “w”.
- Returns:
str/tuple(str, str): Empty string if the output is written to a file. Standard output and error output if no file is given.
- util.makeDirectory(dir)
Creates a directory given a path.
- Args:
dir (str): Path of the directory.
- util.runCommand(command, jobName='', jobs=None, dep='', outFile=None)
Determines whether a command has to be run on SLURM or locally and executes the command using the appropriate function.
It runs locally or on SLURM depending on the configuration in the main.config file, found in the config directory, or if the -hs flag is active.
- Args:
command (str): Command to be executed. jobName (str, optional): Name for the job in case it is executed on SLURM. Defaults to “”. jobs (list, optional): List of jobs where the job ID will be appended in case it is executed on SLURM. Defaults to None. dep (str, optional): List of jobs that must be finished before this job is executed. The list must be a comma-separated string. Only applies for SLURM. Defaults to “”. outFile (str, optional): Path to the output file. Defaults to None.
- Returns:
str/tuple(str, str): Job ID if it is executed on SLURM or it is executed locally and the output is sent to a file. Standard output and error output if it is executed locally and no file is given.
- util.runSlurm(jobName, command, dep='')
Runs the given command on SLURM.
- Args:
jobName (str): Name for the job. command (str): Command to be executed. dep (str, optional): List of jobs that must be finished before this job is executed. The list must be a comma-separated string. Defaults to “”.
- Returns:
str: Job ID.
- util.stopProgram()
Terminates the program.
- util.waitForJobs(jobs)
Waits until all the jobs in a given list are finished running.
- Args:
jobs (list): List of jobs.