Skip to content

Commit

Permalink
Issue-83: Add scripts to run experiments with lab
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskeller79 committed Mar 26, 2020
1 parent febfc1d commit 1641c98
Show file tree
Hide file tree
Showing 5 changed files with 392 additions and 350 deletions.
12 changes: 7 additions & 5 deletions prost.py
Expand Up @@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-

import os
import pathlib
import shutil
import subprocess
import sys


def main():
search_params = []
run_debug = False
Expand All @@ -18,16 +18,18 @@ def main():
else:
search_params.append(arg)

path = pathlib.Path(__file__).parent.absolute()

if run_debug:
parser_name = "rddl-parser-debug"
search_name = "search-debug"
parser_file = "builds/debug/rddl_parser/rddl-parser"
search_file = "builds/debug/search/search"
parser_file = os.path.join(path, "builds/debug/rddl_parser/rddl-parser")
search_file = os.path.join(path, "builds/debug/search/search")
else:
parser_name = "rddl-parser-release"
search_name = "search-release"
parser_file = "builds/release/rddl_parser/rddl-parser"
search_file = "builds/release/search/search"
parser_file = os.path.join(path, "builds/release/rddl_parser/rddl-parser")
search_file = os.path.join(path, "builds/release/search/search")

shutil.copy2(parser_file, "./" + parser_name)
shutil.copy2(search_file, "./" + search_name)
Expand Down
75 changes: 75 additions & 0 deletions testbed/cached_revision.py
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
#
# Prost Lab uses the Lab package to conduct experiments with the
# Prost planning system.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import glob
import os.path
import subprocess

from lab import tools
from lab.cached_revision import CachedRevision


class CachedProstRevision(CachedRevision):
"""This class represents Prost checkouts.
It provides methods for caching and compiling given revisions.
"""

def __init__(self, repo, local_rev, build_options):
"""
* *repo*: Path to Prost repository.
* *local_rev*: Prost revision.
* *build_options*: List of build.py options.
"""
super().__init__(
repo, local_rev, "build.py", build_options, ["scripts"]
)

def get_planner_resource_name(self):
return "prost_" + self._hashed_name

def get_server_resource_name(self):
return "rddlsim_" + self._hashed_name

def get_benchmark_dir_name(self):
return "benchmarks_" + self._hashed_name

def get_wrapper_resource_name(self):
return "wrapper_" + self._hashed_name

def _cleanup(self):
# Only keep the binaries
#for path in glob.glob(os.path.join(self.path, "builds", "*", "*")):
# if os.path.basename(path) not in ["rddl-parser", "search"]:
# tools.remove_path(path)

# Remove unneeded files.
tools.remove_path(self.get_cached_path("build.py"))

# Strip binaries.
binaries = []
for path in glob.glob(os.path.join(self.path, "builds", "*", "*")):
if os.path.basename(path) in ["rddl-parser", "search"]:
binaries.append(path)
subprocess.call(["strip"] + binaries)

# Compress src directory.
subprocess.call(
["tar", "-cf", "src.tar", "--remove-files", "src"], cwd=self.path
)
subprocess.call(["xz", "src.tar"], cwd=self.path)

0 comments on commit 1641c98

Please sign in to comment.