def __init__(self,
                 path=None,
                 repo=None,
                 environment=None,
                 combinations=None,
                 limits=None,
                 attributes=None,
                 derived_properties=None,
                 priority=0,
                 queue=None,
                 processes=2,
                 email=None,
                 cache_dir=CACHE_DIR,
                 **kwargs):
        if path is None:
            path = os.path.splitext(os.path.basename(sys.argv[0]))[0]

        expname = os.path.basename(path)

        remote_exppath = os.path.join(REMOTE_EXPS, path)
        local_exppath = os.path.join(LOCAL_EXPS, path)

        if REMOTE:
            exppath = remote_exppath
            repo = repo or REMOTE_REPO
            environment = environment or MaiaEnvironment(
                priority=priority, queue=queue, email=email)
        else:
            exppath = local_exppath
            repo = repo or LOCAL_REPO
            environment = environment or LocalEnvironment(processes=processes)

        DownwardExperiment.__init__(self,
                                    path=exppath,
                                    environment=environment,
                                    repo=repo,
                                    combinations=combinations,
                                    limits=limits,
                                    cache_dir=cache_dir,
                                    **kwargs)

        self.set_path_to_python(PYTHON)

        if attributes is None:
            attributes = ATTRIBUTES

        # Add report steps
        abs_report_file = os.path.join(self.eval_dir, '%s-abs.html' % expname)
        self.add_report(AbsoluteReport(attributes=attributes,
                                       colored=True,
                                       derived_properties=derived_properties),
                        name='report-abs',
                        outfile=abs_report_file)

        if REMOTE:
            # Compress the experiment directory
            self.add_step(Step.zip_exp_dir(self))
            self.add_step(
                Step('zip-eval-dir',
                     call, [
                         'tar', '-cjf', self.name + '-eval.tar.bz2',
                         self.name + '-eval'
                     ],
                     cwd=os.path.dirname(self.path)))

        self.add_step(Step.remove_exp_dir(self))
        self.add_step(
            Step('remove-eval-dir',
                 shutil.rmtree,
                 self.eval_dir,
                 ignore_errors=True))

        if not REMOTE:
            # Copy the results to local directory
            self.add_step(
                Step('scp-eval-dir', call, [
                    'scp', '-r',
                    '%s:%s-eval' % (SCP_LOGIN, remote_exppath),
                    '%s-eval' % local_exppath
                ]))

            # Copy the results to local directory
            self.add_step(
                Step('scp-zipped-eval-dir', call, [
                    'scp', '-r',
                    '%s:%s-eval.tar.bz2' % (SCP_LOGIN, remote_exppath),
                    '%s-eval.tar.bz2' % local_exppath
                ]))

            # Copy the zipped experiment directory to local directory
            self.add_step(
                Step('scp-exp-dir', call, [
                    'scp', '-r',
                    '%s:%s.tar.bz2' % (SCP_LOGIN, remote_exppath),
                    '%s.tar.bz2' % local_exppath
                ]))

        # Unzip the experiment directory
        self.add_step(Step.unzip_exp_dir(self))
        self.add_step(
            Step('unzip-eval-dir',
                 call, ['tar', '-xjf', self.name + '-eval.tar.bz2'],
                 cwd=os.path.dirname(self.path)))
Exemple #2
0
    def __init__(self, path=None, repo=None, environment=None,
                 combinations=None, limits=None, attributes=None,
                 derived_properties=None, priority=0, queue=None,
                 processes=2, email=None, cache_dir=CACHE_DIR, **kwargs):
        if path is None:
            path = os.path.splitext(os.path.basename(sys.argv[0]))[0]

        expname = os.path.basename(path)

        remote_exppath = os.path.join(REMOTE_EXPS, path)
        local_exppath = os.path.join(LOCAL_EXPS, path)

        if REMOTE:
            exppath = remote_exppath
            repo = repo or REMOTE_REPO
            environment = environment or MaiaEnvironment(priority=priority,
                                                         queue=queue,
                                                         email=email)
        else:
            exppath = local_exppath
            repo = repo or LOCAL_REPO
            environment = environment or LocalEnvironment(processes=processes)

        DownwardExperiment.__init__(self, path=exppath, environment=environment,
                                    repo=repo, combinations=combinations,
                                    limits=limits, cache_dir=cache_dir, **kwargs)

        self.set_path_to_python(PYTHON)

        if attributes is None:
            attributes = ATTRIBUTES

        # Add report steps
        abs_report_file = os.path.join(self.eval_dir, '%s-abs.html' % expname)
        self.add_report(AbsoluteReport(attributes=attributes, colored=True, derived_properties=derived_properties),
                        name='report-abs', outfile=abs_report_file)

        if REMOTE:
            # Compress the experiment directory
            self.add_step(Step.zip_exp_dir(self))
            self.add_step(Step('zip-eval-dir', call,
                               ['tar', '-cjf', self.name + '-eval.tar.bz2', self.name + '-eval'],
                          cwd=os.path.dirname(self.path)))

        self.add_step(Step.remove_exp_dir(self))
        self.add_step(Step('remove-eval-dir', shutil.rmtree, self.eval_dir, ignore_errors=True))

        if not REMOTE:
            # Copy the results to local directory
            self.add_step(Step('scp-eval-dir', call, [
                'scp', '-r',
                '%s:%s-eval' % (SCP_LOGIN, remote_exppath),
                '%s-eval' % local_exppath]))

            # Copy the results to local directory
            self.add_step(Step('scp-zipped-eval-dir', call, [
                'scp', '-r',
                '%s:%s-eval.tar.bz2' % (SCP_LOGIN, remote_exppath),
                '%s-eval.tar.bz2' % local_exppath]))

            # Copy the zipped experiment directory to local directory
            self.add_step(Step('scp-exp-dir', call, [
                'scp', '-r',
                '%s:%s.tar.bz2' % (SCP_LOGIN, remote_exppath),
                '%s.tar.bz2' % local_exppath]))

        # Unzip the experiment directory
        self.add_step(Step.unzip_exp_dir(self))
        self.add_step(Step('unzip-eval-dir', call,
                           ['tar', '-xjf', self.name + '-eval.tar.bz2'],
                      cwd=os.path.dirname(self.path)))
    def __init__(self, path, repo, opt_or_sat, rev, base_rev=None,
                 use_core_configs=True, use_ipc_configs=True, use_extended_configs=False,
                 **kwargs):
        """
        See :py:class:`DownwardExperiment <downward.experiments.DownwardExperiment>`
        for inherited parameters.

        The experiment will be built at *path*.

        *repo* must be the path to a Fast Downward repository. This repository
        is used to search for problem files.

        If *opt_or_sat* is 'opt', configurations for optimal planning will be
        tested on all domains suited for optimal planning. If it is 'sat',
        configurations for satisficing planning will be tested on the
        satisficing suite.

        *rev* determines the new revision to test.

        If *base_rev* is None (default), the latest revision on the branch default
        that is an ancestor of *rev* will be used.

        *use_core_configs* determines if the most common configurations are tested
        (default: True).

        *use_ipc_configs* determines if the configurations used in the IPCs are tested
        (default: True).

        *use_extended_configs* determines if some less common configurations are tested
        (default: False).

        """
        base_rev = checkouts.get_common_ancestor(repo, rev)
        combos = [(Translator(repo, rev=r),
                   Preprocessor(repo, rev=r),
                   Planner(repo, rev=r))
                  for r in (base_rev, rev)]
        DownwardExperiment.__init__(self, path, repo, combinations=combos, **kwargs)

        # ------ suites and configs ------------------------------------

        if opt_or_sat == 'opt':
            self.add_suite(suite_optimal_with_ipc11())
            configs = default_configs_optimal(use_core_configs,
                                              use_ipc_configs,
                                              use_extended_configs)
        elif opt_or_sat == 'sat':
            self.add_suite(suite_satisficing_with_ipc11())
            configs = default_configs_satisficing(use_core_configs,
                                                  use_ipc_configs,
                                                  use_extended_configs)
        else:
            logging.critical('Select to test either \'opt\' or \'sat\' configurations')

        for nick, command in configs.items():
            self.add_config(nick, command)

        # ------ reports -----------------------------------------------

        comparison = CompareRevisionsReport(base_rev,
                                            rev,
                                            attributes=COMPARED_ATTRIBUTES)
        self.add_report(comparison,
                        name='report-compare-scores',
                        outfile='report-compare-scores.html')

        for nick in configs.keys():
            config_before = '%s-%s' % (base_rev, nick)
            config_after = '%s-%s' % (rev, nick)
            for attribute in SCATTER_PLOT_ATTRIBUTES:
                name = 'scatter-%s-%s' % (attribute, nick)
                self.add_report(
                    ScatterPlotReport(
                        filter_config=[config_before, config_after],
                        attributes=[attribute],
                        get_category=lambda run1, run2: run1['domain']),
                    outfile=name)