Skip to content

Commit

Permalink
Print statistics in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
vmordan committed Oct 27, 2023
1 parent 9f2ee78 commit 19eabbe
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@
TAG_UPLOADER = "uploader"
TAG_NAME = "name"
TAG_IDENTIFIER = "identifier"
TAG_CVV_USER = "user"
TAG_CVV_PASS = "password"
TAG_CVV_HOST = "server"

DEFAULT_CONFIG_COMMAND = "allmodconfig"
DEFAULT_ARCH = "x86_64"
BUILDER_SCRIPT = os.path.join("klever", "deploys", "builder.sh")
COMPARATOR_SCRIPT = os.path.join("tools", "cvv", "utils", "bin", "get-compare-data.py")
KLEVER_LAUNCH_SCRIPT = "klever-start-solution"
KLEVER_CHECK_SCRIPT = "klever-download-progress"
DEFAULT_VENV_PATH = "venv/bin"
Expand All @@ -80,7 +84,7 @@
COMPONENT_RUNNER = "Runner"
KLEVER_TASKS_DIR = os.path.join("klever-work", "native-scheduler", "scheduler", "tasks")
BUILD_BASE_STORAGE_DIR = "Storage"

RESULT_FILE = "runner_result.log"
BIG_WAIT_INTERVAL = 100
SMALL_WAIT_INTERVAL = 10

Expand Down Expand Up @@ -195,6 +199,10 @@ def __update_job_config(self, build_base_dir: str):
with open(self.bridge_config, 'w', encoding='ascii') as f_bconfig:
json.dump(bridge_config, f_bconfig, sort_keys=True, indent=4)

@staticmethod
def __create_credentials(user: str, password: str, host: str) -> str:
return f"--host {host} --username {user} --password {password}"

def klever(self, build_base_dir: str) -> str:
"""
Create a new Klever job and launch it.
Expand All @@ -205,7 +213,7 @@ def clear_klever_resources():
self.logger.info("Launching Klever tool")
wall_time_start = time.time()
self.__update_job_config(build_base_dir)
credentials = f"--host {self.klever_host} --username {self.klever_user} --password {self.klever_pass}"
credentials = self.__create_credentials(self.klever_user, self.klever_pass, self.klever_host)
replacement = f"{{\"job.json\": \"{self.job_config}\", \"tasks.json\": \"{self.resource_config}\"," \
f"\"verifier profiles.json\": \"{self.verifier_options_config}\"}}"
cmd = f"{KLEVER_LAUNCH_SCRIPT} {credentials} --rundata {self.launch_config} " \
Expand Down Expand Up @@ -256,13 +264,29 @@ def bridge(self, new_job_id: str):
shutil.rmtree(os.path.join(self.jobs_dir, new_job_id), ignore_errors=True)
self.command_caller("service klever-native-scheduler restart")

def print_statistics(self):
if self.parent_job_id:
with open(self.bridge_config, errors='ignore', encoding='ascii') as f_bconfig:
bridge_config = json.load(f_bconfig)
cvv_pass = bridge_config[TAG_UPLOADER][TAG_CVV_PASS]
cvv_user = bridge_config[TAG_UPLOADER][TAG_CVV_USER]
cvv_host = bridge_config[TAG_UPLOADER][TAG_CVV_HOST]
credentials = self.__create_credentials(cvv_user, cvv_pass, cvv_host)
os.chdir(self.bridge_dir)
cvv_python_path = os.path.abspath(os.path.join(os.path.dirname(COMPARATOR_SCRIPT), os.path.pardir))
command = f"PYTHONPATH={cvv_python_path} {COMPARATOR_SCRIPT} {credentials} {self.parent_job_id} > " \
f"{RESULT_FILE}"
self.logger.debug(command)
self.command_caller(command)

def run(self):
"""
Performs full run.
"""
build_base_dir = self.builder()
new_job_id = self.klever(build_base_dir)
self.bridge(new_job_id)
self.print_statistics()


if __name__ == '__main__':
Expand Down

0 comments on commit 19eabbe

Please sign in to comment.