示例#1
0
 def check_paths(self, conf):
     error_message = "Error in configuration-file:\n\n"
     exception_occured = False
     for build_dir in conf.directories:
         if not (util.check_provided_directory(build_dir)):
             error_message += "Build-directory " + build_dir + " does not exist.\n\n"
             exception_occured = True
         for item in conf.builds[build_dir][_ITEMS]:
             for inst_ana in conf.items[build_dir][item][
                     "instrument_analysis"]:
                 if not (util.check_provided_directory(inst_ana)):
                     error_message += "Instrument-analysis directory " + inst_ana + " does not exist.\n"
                     exception_occured = True
             if not (util.check_provided_directory(
                     conf.items[build_dir][item]["builders"])):
                 error_message += "Builders-directory " + conf.items[
                     build_dir][item]["builders"] + " does not exist.\n"
                 exception_occured = True
             for arg in conf.items[build_dir][item]["args"]:
                 if not (util.check_provided_directory(arg)):
                     error_message += "args" + arg + "does not exist.\n"
                     exception_occured = True
                 if not (util.check_provided_directory(
                         conf.items[build_dir][item]["runner"])):
                     error_message += "runner" + conf.items[build_dir][
                         item]["runner"] + "does not exist.\n"
                     exception_occured = True
         if exception_occured:
             raise PiraConfigurationErrorException(error_message)
示例#2
0
    def check_paths(self, config):
        error_message = "Error in configuration-file:\n\n"
        exception_occured = False

        for dir in config.get_directories():
            if not (util.check_provided_directory(dir)):
                error_message += "Directory " + dir + " does not exist.\n"
                exception_occured = True
            for item in config.get_items(dir):
                if not (util.check_provided_directory(
                        item.get_analyzer_dir())):
                    error_message += "Analyzer-Directory " + item.get_analyzer_dir(
                    ) + " does not exist\n"
                    exception_occured = True
                if not (util.check_provided_directory(
                        item.get_analyzer_dir())):
                    error_message += "Cubes-Directory " + item.get_cubes_dir(
                    ) + " does not exist\n"
                    exception_occured = True
                if not (util.check_provided_directory(
                        item.get_functor_base_path())):
                    error_message += "Functors-Base-Directory " + item.get_functor_base_path(
                    ) + " does not exist\n"
                    exception_occured = True
                for flavor in item.get_flavors():
                    if not (util.is_file(item.get_functor_base_path() +
                                         "/analyse_" + item._name + "_" +
                                         flavor + ".py")):
                        error_message += "analyse-functor of flavor " + flavor + " does not exist.\n"
                        exception_occured = True
                    if not (util.is_file(item.get_functor_base_path() +
                                         "/clean_" + item._name + "_" +
                                         flavor + ".py")):
                        error_message += "clean-functor of flavor " + flavor + " does not exist.\n"
                        exception_occured = True
                    if not (util.is_file(item.get_functor_base_path() +
                                         "/no_instr_" + item._name + "_" +
                                         flavor + ".py")):
                        error_message += "no_instr-functor of flavor " + flavor + " does not exist.\n"
                        exception_occured = True
                    if not (util.is_file(item.get_functor_base_path() +
                                         "/runner_" + item._name + "_" +
                                         flavor + ".py")):
                        error_message += "runner-functor of flavor " + flavor + " does not exist.\n"
                        exception_occured = True
                    if not (util.is_file(item.get_functor_base_path() + "/" +
                                         item._name + "_" + flavor + ".py")):
                        error_message += "plain-functor of flavor " + flavor + " does not exist.\n"
                        exception_occured = True

        if exception_occured:
            raise PiraConfigurationErrorException(error_message)
示例#3
0
    def _set_up(self, build, item, flavor, it_nr, is_instr_run) -> None:
        L.get_logger().log('ScorepSystemHelper::_set_up: is_instr_run: ' +
                           str(is_instr_run),
                           level='debug')
        if not is_instr_run:
            return

        exp_dir = self.config.get_analyzer_exp_dir(build, item)
        L.get_logger().log(
            'ScorepSystemHelper::_set_up: Retrieved analyzer experiment directory: '
            + exp_dir,
            level='debug')
        effective_dir = U.get_cube_file_path(exp_dir, flavor, it_nr)
        if not U.check_provided_directory(effective_dir):
            L.get_logger().log(
                'ScorepSystemHelper::_set_up: Experiment directory does not exist.  \nCreating path: '
                + effective_dir,
                level='debug')
            U.create_directory(effective_dir)

        db_exp_dir = U.build_cube_file_path_for_db(exp_dir, flavor, it_nr)
        self.data['cube_dir'] = db_exp_dir
        self.set_exp_dir(exp_dir, flavor, it_nr)
        self.set_memory_size('500M')
        self.set_overwrite_exp_dir()
        self.set_profiling_basename(flavor, build, item)
示例#4
0
    def check_and_prepare(self, experiment_dir: str,
                          target_config: TargetConfiguration,
                          instr_config: InstrumentConfig) -> str:
        cur_ep_dir = self.get_extrap_dir_name(
            target_config, instr_config.get_instrumentation_iteration())
        if not u.is_valid_file_name(cur_ep_dir):
            log.get_logger().log(
                'ExtrapProfileSink::check_and_prepare: Generated directory name no good. Abort\n'
                + cur_ep_dir,
                level='error')
        else:
            if u.check_provided_directory(cur_ep_dir):
                new_dir_name = cur_ep_dir + '_' + u.generate_random_string()
                log.get_logger().log(
                    'ExtrapProfileSink::check_and_prepare: Moving old experiment directory to: '
                    + new_dir_name,
                    level='info')
                u.rename(cur_ep_dir, new_dir_name)

            u.create_directory(cur_ep_dir)
            cubex_name = experiment_dir + '/' + target_config.get_flavor(
            ) + '-' + target_config.get_target() + '.cubex'
            log.get_logger().log(cubex_name)

            if not u.is_file(cubex_name):
                log.get_logger().log(
                    'ExtrapProfileSink::check_and_prepare: Returned experiment cube name is no file: '
                    + cubex_name)
            else:
                return cubex_name

        raise ProfileSinkException(
            'ExtrapProfileSink: Could not create target directory or Cube dir bad.'
        )
示例#5
0
文件: Analyzer.py 项目: mority/pira
 def tear_down(self, old_dir, exp_dir):
     isdirectory_good = U.check_provided_directory(exp_dir)
     if isdirectory_good:
         try:
             U.change_cwd(old_dir)
         except Exception as e:
             L.get_logger().log(str(e), level='error')
示例#6
0
文件: Builder.py 项目: mority/pira
 def set_up(self) -> None:
   L.get_logger().log('Builder::set_up for ' + self.directory)
   directory_good = U.check_provided_directory(self.directory)
   if directory_good:
     self.old_cwd = U.get_cwd()
     U.change_cwd(self.directory)
   else:
     self.error = True
     raise Exception('Builder::set_up: Could not change to directory')
示例#7
0
  def check_configfile_v1(configuration):

    error_message ="Error in configuration-file:\n\n"
    exception_occured = False

    for build_dir in configuration.directories:
      if not(util.check_provided_directory(build_dir)):
        error_message += "Build-directory " +build_dir+ " does not exist.\n\n"
        exception_occured = True

      for item in configuration.builds[build_dir]['items']:
        analysis_functor_dir = configuration.items[build_dir][item]['instrument_analysis'][0]

        if not (util.check_provided_directory(analysis_functor_dir)):
          error_message += "Analysis-functor dir " + analysis_functor_dir  + " does not exist.\n"
          exception_occured = True

        analysis_binary_dir = configuration.items[build_dir][item]['instrument_analysis'][2]
        if not (util.check_provided_directory(analysis_binary_dir)):
          error_message += "Analysis-functor dir " + analysis_binary_dir  + " does not exist.\n"
          exception_occured = True

        cubes_dir = configuration.items[build_dir][item]['instrument_analysis'][1]
        if not(util.check_provided_directory(cubes_dir)):
          log.get_logger().log("Creating Cubes-Directory" + cubes_dir , level='info')

        if not(util.check_provided_directory(configuration.items[build_dir][item]["builders"])):
          error_message += "Builders-directory " + configuration.items[build_dir][item]["builders"] + " does not exist.\n"
          exception_occured = True

        for arg in configuration.items[build_dir][item]["args"]:
          if not(util.check_provided_directory(arg)):
            error_message += "args" + arg + "does not exist.\n"
            exception_occured = True

          if not(util.check_provided_directory(configuration.items[build_dir][item]["runner"])):
            error_message += "runner" + configuration.items[build_dir][item]["runner"] + "does not exist.\n"
            exception_occured = True

      if exception_occured:
        raise config.PiraConfigurationErrorException(error_message)
示例#8
0
 def test_check_provided_directory(self):
   self.assertTrue(u.check_provided_directory('/home'))
   self.assertFalse(u.check_provided_directory('/glibberish/asdf'))
示例#9
0
  def check_configfile_v2(configuration):

    if isinstance(configuration, config.PiraConfigurationAdapter):
      configuration = configuration.get_adapted()

    error_message = "Error in configuration-file:\n\n"
    exception_occured = False

    for dir in configuration.get_directories():
      if not (util.check_provided_directory(configuration.get_place(dir))):
        error_message += "Directory " + dir + " does not exist.\n"
        exception_occured = True

      # check if directories exist
      for item in configuration.get_items(dir):
        if not (util.check_provided_directory(item.get_analyzer_dir())):
          error_message += "Analyzer-Directory " + item.get_analyzer_dir() + " does not exist\n"
          exception_occured = True

        # instead of throwing an error, only an info is logged. This is due to that the directory is created in ProfileSink
        if not (util.check_provided_directory(item.get_cubes_dir())):
          log.get_logger().log("Creating Cubes-Directory" + item.get_cubes_dir(), level='info')

        if not (util.check_provided_directory(item.get_functor_base_path())):
          error_message += "Functors-Base-Directory " + item.get_functor_base_path() + " does not exist\n"
          exception_occured = True

        # if there is no flavor,the flavors-array is filled with an empty entry and the underscore in the filename is removed
        if len(item.get_flavors()) == 0 :
          flavors = ['']
          underscore = ''

        else:
          flavors = item.get_flavors()
          underscore = "_"

        # check if functor-files exist
        for flavor in flavors:
          if not (util.is_file(item.get_functor_base_path() + "/analyse_" + item._name + underscore + flavor + ".py")):
            error_message += "analyse-functor of flavor " + flavor + " does not exist" + ".\n"
            exception_occured = True

          if not (util.is_file(item.get_functor_base_path() + "/clean_" + item._name + underscore + flavor + ".py")):
            error_message += "clean-functor of flavor " + flavor + " does not exist.\n"
            exception_occured = True

          if not (util.is_file(item.get_functor_base_path() + "/no_instr_" + item._name + underscore + flavor + ".py")):
            error_message += "no_instr-functor of flavor " + flavor + " does not exist.\n"
            exception_occured = True

          if not (util.is_file(item.get_functor_base_path() + "/runner_" + item._name + underscore + flavor + ".py")):
            error_message += "runner-functor of flavor " + flavor + " does not exist.\n"
            exception_occured = True

          if not (util.is_file(item.get_functor_base_path() + "/" + item._name + underscore + flavor + ".py")):
            error_message += "plain-functor of flavor " + flavor + " in item " + item._name + " does not exist.\n"
            exception_occured = True


    if exception_occured:
      raise config.PiraConfigurationErrorException(error_message)
示例#10
0
文件: Analyzer.py 项目: mority/pira
    def analyze_local(self, flavor: str, build: str, benchmark: str,
                      kwargs: dict, iterationNumber: int) -> str:
        fm = F.FunctorManager()
        analyze_functor = fm.get_or_load_functor(build, benchmark, flavor,
                                                 'analyze')
        analyzer_dir = self.config.get_analyzer_dir(build, benchmark)
        kwargs['analyzer_dir'] = analyzer_dir

        # The invoke args can be retrieved from the configuration object.
        # Since the invoke args are iterable, we can create all necessary argument tuples here.

        # We construct a json file that contains the necesary information to be parsed vy the
        # PGIS tool. That way, we can make it easily traceable and debug from manual inspection.
        # This will be the new standard way of pusing information to PGIS.
        pgis_cfg_file = None
        if self._profile_sink.has_config_output():
            pgis_cfg_file = self._profile_sink.output_config(
                benchmark, analyzer_dir)

        if analyze_functor.get_method()['active']:
            analyze_functor.active(benchmark, **kwargs)

        else:
            L.get_logger().log('Analyzer::analyze_local: Using passive mode')
            try:
                exp_dir = self.config.get_analyzer_exp_dir(build, benchmark)
                isdirectory_good = U.check_provided_directory(analyzer_dir)
                command = analyze_functor.passive(benchmark, **kwargs)

                L.get_logger().log('Analyzer::analyze_local: Command = ' +
                                   command)

                benchmark_name = self.config.get_benchmark_name(benchmark)

                if isdirectory_good:
                    U.change_cwd(analyzer_dir)
                    L.get_logger().log('Analyzer::analyzer_local: Flavor = ' +
                                       flavor + ' | benchmark_name = ' +
                                       benchmark_name)
                    instr_files = U.build_instr_file_path(
                        analyzer_dir, flavor, benchmark_name)
                    L.get_logger().log(
                        'Analyzer::analyzer_local: instrumentation file = ' +
                        instr_files)
                    prev_instr_file = U.build_previous_instr_file_path(
                        analyzer_dir, flavor, benchmark_name)

                tracker = T.TimeTracker()

                # TODO: Alternate between expansion and pure filtering.

                if iterationNumber > 0 and U.is_file(instr_files):
                    L.get_logger().log(
                        'Analyzer::analyze_local: instr_file available')
                    U.rename(instr_files, prev_instr_file)
                    tracker.m_track('Analysis', U, 'run_analyzer_command',
                                    command, analyzer_dir, flavor,
                                    benchmark_name, exp_dir, iterationNumber,
                                    pgis_cfg_file)
                    L.get_logger().log(
                        'Analyzer::analyze_local: command finished',
                        level='debug')
                else:

                    tracker.m_track('Initial analysis', U,
                                    'run_analyzer_command_noInstr', command,
                                    analyzer_dir, flavor, benchmark_name)

                self.tear_down(build, exp_dir)
                return instr_files

            except Exception as e:
                L.get_logger().log(str(e), level='error')
                raise Exception('Problem in Analyzer')