Skip to content

Commit

Permalink
Merge pull request #149 from PDXCapstoneF/bs-run-cwd
Browse files Browse the repository at this point in the history
Set working directory for runs
  • Loading branch information
benjspriggs authored May 17, 2018
2 parents 290d86f + 21b03a4 commit d0766fc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions 68c5021657bc484bafdb70cb5bc3db74/specjbb2015.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[SPECtate]

2 changes: 2 additions & 0 deletions cd3405055e524b47942bcd5f2da5f6c2/specjbb2015.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[SPECtate]

2 changes: 2 additions & 0 deletions d232e5d507f34acdb57c3dec3f92a534/specjbb2015.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[SPECtate]

22 changes: 12 additions & 10 deletions src/benchmark_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def __init__(self,
controller=None,
backends=None,
injectors=None,
cwd=None,
java=None,
jar=None,
tag=None,
Expand All @@ -215,6 +216,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
Expand Down Expand Up @@ -288,8 +290,8 @@ def run(self, dry_run=False):
`dry_run` sets whether or not to actually run the JVMs associated with
this run.
"""
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 run directory to {}".format(results_directory))

Expand All @@ -299,25 +301,25 @@ def run(self, dry_run=False):
try:
self.log.debug(
"attempting to create results directory {}".format(results_directory))
try:
os.mkdir(results_directory)
except os.FileExistsError:
self.log.debug(
"run results directory already existed, continuing")
os.mkdir(results_directory)
except os.FileExistsError:
self.log.error(
"run results directory already existed, continuing")

os.chdir(results_directory)
os.chdir(results_directory)

try:
for number_of_times in range(self.times):
self.log.debug(
"beginning run {}/{}".format(number_of_times, self.times))
self._run(dry_run)

except Exception as e:
self.log.error(
"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, dry_run=False):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/run_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
RunGenerator, and it updates itself to have a list of
all the runs present in that configuration.
"""
import os
from src.validate import TemplateDataSchema, RunConfigSchema, random_run_id



class RunGenerator:
"""
This class is responsible for taking a Tate config and
Expand Down Expand Up @@ -66,6 +66,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"],
'tag': run["tag"] if "tag" in run else random_run_id(),
Expand Down
1 change: 1 addition & 0 deletions src/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def random_run_id():
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,
},
Expand Down

0 comments on commit d0766fc

Please sign in to comment.