def handler(event, context): """ Run on AWS Lambda. """ config_file = "config.dev.json" if context.function_name == "autotune-prod-mentalmodels": config_file = "config.prod.json" autotune = Autotune(config_file, event['ID']) memory = Memory(autotune) networking = Networking(autotune) ai_features = dict(memory.ai_features().items() + networking.ai_features().items()) procfs_features = dict(memory.procfs_features().items() + networking.procfs_features().items()) sysfs_features = dict(memory.sysfs_features().items() + networking.sysfs_features().items()) autotune.write_ai_features(ai_features) autotune.write_procfs_features(procfs_features) autotune.write_sysfs_features(sysfs_features) autotune.close() return { 'Message': "OK" }
def run_model(config_file, event_id): print "Running {}".format(event_id) autotune = Autotune(config_file) autotune.get_id(event_id) memory = Memory(autotune) networking = Networking(autotune) ai_features = dict(memory.ai_features().items() + networking.ai_features().items()) procfs_features = dict(memory.procfs_features().items() + networking.procfs_features().items()) sysfs_features = dict(memory.sysfs_features().items() + networking.sysfs_features().items()) autotune.write_ai_features(ai_features) autotune.write_procfs_features(procfs_features) autotune.write_sysfs_features(sysfs_features) autotune.close()
def run_model(config_file, machine_id): print "Running {}".format(machine_id) machine = Machine(config_file) machine.get_id(machine_id) memory = Memory(machine) networking = Networking(machine) ai_features = dict(memory.ai_features().items() + networking.ai_features().items()) procfs_features = dict(memory.procfs_features().items() + networking.procfs_features().items()) sysfs_features = dict(memory.sysfs_features().items() + networking.sysfs_features().items()) machine.write_features('ai_features', ai_features) machine.write_features('procfs', procfs_features) machine.write_features('sysfs', sysfs_features) machine.write_features('quick', { 'Security': 0, 'Stats': len(procfs_features) + len(sysfs_features), })