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.' )
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')