def check_config(cls, config): # First let's check all common sections entries check_params = cls.general_params() backend_sections = cls.get_backend_sections() study_sections = cls.get_study_sections() # filter out commented sections (e.g., [*backend_section:tag]) config_sections = [ section for section in config.keys() if section.split(":")[0][0] != "*" ] for section in config_sections: if Task.get_backend(section) in backend_sections: # backend_section:tag continue if section.startswith((study_sections)): continue if section not in check_params.keys(): raise RuntimeError("Wrong section:", section) # Check the params for the section for param in config[section].keys(): if param not in check_params[section]: raise RuntimeError("Wrong section param:", section, param) for param in check_params[section]: if param not in config[section].keys(): if not check_params[section][param]['optional']: raise RuntimeError("Missing section param:", section, param) else: # Add the default value for this param config[section][param] = check_params[section][param][ 'default'] else: ptype = type(config[section][param]) ptype_ok = check_params[section][param]["type"] ptype_default = check_params[section][param]["default"] if ptype != ptype_ok and ptype_default is not None: msg = "Wrong type for section param: %s %s %s should be %s" % \ (section, param, ptype, ptype_ok) raise RuntimeError(msg) # And now the backend_section entries # A backend section entry could have specific perceval params which are # not checked check_params = cls.backend_section_params() for section in config_sections: if Task.get_backend(section) in backend_sections: for param in check_params: if param not in config[section].keys(): if not check_params[param]['optional']: raise RuntimeError("Missing section param:", section, param) else: ptype = type(config[section][param]) ptype_ok = check_params[param]["type"] if ptype != ptype_ok: msg = "Wrong type for section param: %s %s %s should be %s" % \ (section, param, ptype, ptype_ok) raise RuntimeError(msg)
def check_config(cls, config): # First let's check all common sections entries check_params = cls.general_params() backend_sections = cls.get_backend_sections() study_sections = cls.get_study_sections() # filter out commented sections (e.g., [*backend_section:tag]) config_sections = [section for section in config.keys() if section.split(":")[0][0] != "*"] for section in config_sections: if Task.get_backend(section) in backend_sections: # backend_section:tag continue if section.startswith((study_sections)): continue if section not in check_params.keys(): raise RuntimeError("Wrong section:", section) # Check the params for the section for param in config[section].keys(): if param not in check_params[section]: raise RuntimeError("Wrong section param:", section, param) for param in check_params[section]: if param not in config[section].keys(): if not check_params[section][param]['optional']: raise RuntimeError("Missing section param:", section, param) else: # Add the default value for this param config[section][param] = check_params[section][param]['default'] else: ptype = type(config[section][param]) ptype_ok = check_params[section][param]["type"] ptype_default = check_params[section][param]["default"] if ptype != ptype_ok and ptype_default is not None: msg = "Wrong type for section param: %s %s %s should be %s" % \ (section, param, ptype, ptype_ok) raise RuntimeError(msg) # And now the backend_section entries # This only validates the types of each param if present, and doesn't check that # all required parameters are set. This functionality has been moved to the # get_backend_section method check_params = cls.backend_section_params() for section in config_sections: if Task.get_backend(section) in backend_sections: for param in check_params: if param in config[section].keys(): ptype = type(config[section][param]) ptype_ok = check_params[param]["type"] if ptype != ptype_ok: msg = "Wrong type for section param: %s %s %s should be %s" % \ (section, param, ptype, ptype_ok) raise RuntimeError(msg)
def _get_repos_by_backend(self): # # return dict with backend and list of repositories # output = {} projects = TaskProjects.get_projects() for backend_section in Config.get_backend_sections(): for pro in projects: backend = Task.get_backend(backend_section) if backend in projects[pro]: if backend_section not in output: output[backend_section] = projects[pro][backend] else: output[backend_section] += projects[pro][backend] # backend could be in project/repo file but not enabled in # sirmordred conf file enabled = {} for k in output: if k in self.conf: enabled[k] = output[k] # logger.debug('repos to be retrieved: %s ', enabled) return enabled
def get_repos_by_backend_section(cls, backend_section): """ return list with the repositories for a backend_section """ repos = [] projects = TaskProjects.get_projects() for pro in projects: if backend_section in projects[pro]: backend = Task.get_backend(backend_section) if backend in Config.get_global_data_sources() and cls.GLOBAL_PROJECT in projects \ and pro != cls.GLOBAL_PROJECT: logger.debug("Skip global data source %s for project %s", backend, pro) else: repos += projects[pro][backend_section] logger.debug("List of repos for %s: %s", backend_section, repos) return repos