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)
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 check_build_prerequisites(cls) -> None: scorep_init_file_name = 'scorep.init.c' L.get_logger().log( 'ScorepMeasurementSystem::check_build_prerequisites: global home dir: ' + U.get_home_dir()) pira_scorep_resource = U.get_home_dir() + '/resources/scorep.init.c' if not U.is_file(scorep_init_file_name): U.copy_file(pira_scorep_resource, U.get_cwd() + '/' + scorep_init_file_name) # In case something goes wrong with copying if U.is_file(scorep_init_file_name): U.shell('gcc -c ' + scorep_init_file_name) else: raise MeasurementSystemException( 'ScorepMeasurementSystem::check_build_prerequisites: Missing ' + scorep_init_file_name)
def load_conf(self, config_file: str) -> PiraConfiguration: if not U.is_file(config_file): raise RuntimeError( 'SimplifiedConfigurationLoader::load_conf: Invalid config file location "' + config_file + '" [no such file].') config_abs = U.get_absolute_path(config_file) config_abs_path = config_abs[:config_abs.rfind('/')] self._config.set_absolute_base_path(config_abs_path) try: file_content = U.read_file(config_file) json_tree = json.loads(file_content) self.parse_from_json(json_tree) except Exception as e: L.get_logger().log( 'SimplifiedConfigurationLoader::load_conf: Caught exception "' + str(e)) return PiraConfigurationAdapter(self._config)
def check_queued_job(): return U.is_file(queued_job_filename)
def test_check_file(self): self.assertTrue(u.is_file('/bin/sh')) self.assertFalse(u.is_file('/bin/ushsdnsdhh'))
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)
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')