API¶
This section lists all of the classes, functions and variables implemented in heiko.
Schedulers¶
-
class
heiko.schedulers.BasicScheduler(config: heiko.config.Config)¶ A very simple scheduler that uses a priority queue to iterate through the avaiable nodes and tries to run the FIRST JOB on one node. If the node fails, the scheduler tries the next available node and so on.
The nodes are sorted based on
heiko.utils.load.NodeDetails.- Parameters
config (
heiko.config.Config.) – configuration object
-
nodeDetail(node)¶ Adds a new node to the nodelist with its details
- Parameters
node (
heiko.config.Node.) – node to add
-
run()¶ Runs the scheduler until interrupted.
-
updateNode(detail: heiko.utils.load.NodeDetails)¶ Updates details of a node
- Parameters
detail (
heiko.utils.load.NodeDetails) – details of the node to be updated
Configuration¶
-
class
heiko.config.Config(name, config_file=None)¶ Class to read and parse configuration files file(s)
The configuration files should be plain YAML files.
- Parameters
config_file – location of configuration file. default is
./.heiko/config.yml.
-
property
first_job¶ Returns the first job
-
property
first_node¶ Returns the first node from the config
Daemon¶
-
class
heiko.daemon.Daemon(pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')¶ A generic daemon class.
Implementation taken from: https://stackoverflow.com/a/6374881/11199009
Usage: subclass the Daemon class and override the run() method
-
daemonize()¶ do the UNIX double-fork magic, see Stevens’ “Advanced Programming in the UNIX Environment” for details (ISBN 0201563177) http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
-
delpid()¶
-
property
pid¶
-
restart()¶ Restart the daemon
-
run()¶ You should override this method when you subclass Daemon. It will be called after the process has been daemonized by start() or restart().
-
start()¶ Start the daemon
-
stop()¶ Stop the daemon
-
Utilities¶
Load Utilities¶
-
class
heiko.utils.load.NodeDetails(node: heiko.config.Node)¶ Class to store details of a node such as CPU frequency, no of virtual CPUs, load average, total memory, memory usage, etc.
- Parameters
node (
heiko.config.Node.) – node to store details of
-
async
getCpuDetails(conn)¶ Gets CPU details of the node using the
sysfssubsystem.- Parameters
conn – asynchssh connection object
- Returns
output of the command
- Return type
str
-
async
getCpuUsage(conn)¶ Gets CPU usage (load average) of the node using the
/proc/loadavgfile.- Parameters
conn – asynchssh connection object
- Returns
output of the command
- Return type
str
-
async
getDetails()¶ Gets and saves all details of the node
-
async
getNodeRam(conn)¶ Gets RAM details of the node using the
/proc/meminfofile.- Parameters
conn – asynchssh connection object
- Returns
output of the command
- Return type
str
-
parseCpuInfo(info)¶
-
parseLoad(load)¶
-
parserRam(ram)¶
SSH Utilities¶
-
class
heiko.utils.ssh.HeikoSSHClientSession¶ A class to handle SSH connections cleanly
-
connection_lost(exc)¶ Prints an error message to stderr
-
data_received(data, datatype)¶ Prints the received data directly
-
-
async
heiko.utils.ssh.run_client(node: heiko.config.Node, commands: List)¶ Runs given job on given node
- Parameters
node (
heiko.config.Node) – node to run onjob (
heiko.config.Job) – job to run