From bb0c6ded33dd2715cd82038263b79554e4c0d959 Mon Sep 17 00:00:00 2001 From: bspriggs Date: Sun, 13 May 2018 16:05:07 -0700 Subject: [PATCH 1/3] Take cwd as a parameter, change into results directory before doing run a certain number of times --- src/benchmark_run.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/benchmark_run.py b/src/benchmark_run.py index 28a6cd2..b99afdd 100644 --- a/src/benchmark_run.py +++ b/src/benchmark_run.py @@ -185,6 +185,7 @@ def __init__(self, controller=None, backends=None, injectors=None, + cwd=None, java=None, jar=None, times=1, @@ -205,6 +206,7 @@ def __init__(self, if None in [java, jar] or not isinstance(jar, str): raise InvalidRunConfigurationException + self.cwd = os.path.abspath(cwd) if cwd else os.getcwd() self.jar = os.path.abspath(jar) self.times = times self.props = props @@ -272,8 +274,7 @@ def _generate_tasks(self): '-J={}'.format(ti_jvm_id)) def run(self): - pwd = os.getcwd() - results_directory = os.path.abspath(str(self.run_id)) + results_directory = os.path.join(self.cwd, str(self.run_id)) self.log.debug("set logging directory to {}".format(results_directory)) @@ -283,9 +284,11 @@ def run(self): try: os.mkdir(results_directory) except os.FileExistsError: - self.log.debug( + self.log.error( "run results directory already existed, continuing") + os.chdir(results_directory) + for number_of_times in range(self.times): self.log.debug( "beginning run {}/{}".format(number_of_times, self.times)) @@ -296,7 +299,8 @@ def run(self): "exception: {}, removing results directory".format(e)) shutil.rmtree(results_directory) finally: - os.chdir(pwd) + self.log.info("returning to {}".format(self.cwd)) + os.chdir(self.cwd) def _run(self): """ From f9f08cc7a5a9ceafca139068e29bdeb791209380 Mon Sep 17 00:00:00 2001 From: bspriggs Date: Sun, 13 May 2018 16:05:23 -0700 Subject: [PATCH 2/3] Pass cwd to run list in RunGenerator --- src/run_generator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/run_generator.py b/src/run_generator.py index 1e9a87f..dae51ec 100644 --- a/src/run_generator.py +++ b/src/run_generator.py @@ -1,3 +1,4 @@ +import os from src.validate import TemplateSchema, RunConfigSchema @@ -37,6 +38,7 @@ def __init__(self, TemplateData=None, RunList=None): }, 'backends': backends, 'injectors': injectors, + 'cwd': template["cwd"] if "cwd" in template else os.getcwd(), 'java': template["java"], 'jar': template["jar"], 'times': run["times"], From 4ab3ac0008554df4d4ef7eb73a4af3ad9a890242 Mon Sep 17 00:00:00 2001 From: bspriggs Date: Sun, 13 May 2018 16:05:35 -0700 Subject: [PATCH 3/3] Add key for cwd in template type --- src/validate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/validate.py b/src/validate.py index 65e3a98..ec74ce5 100644 --- a/src/validate.py +++ b/src/validate.py @@ -13,6 +13,7 @@ def is_stringy(v): Optional("run_type", default="composite"): And(is_stringy, lambda rt: rt.lower() in ["multi", "composite", "distributed_ctrl_txl", "distributed_sut"]), Optional("java", default="java"): is_stringy, Optional("jar", default="specjbb2015.jar"): is_stringy, + Optional("cwd"): is_stringy, Optional("prop_options"): { is_stringy: object, },