Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print statistics in runner #52

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 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,32 @@ 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):
"""
Print comparison data with the previous run.
"""
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