def _resolve_config(config): """Resolve the config file if global ('network' and 'simulation' keys). Args: config (str/dict): the path to the configuration file or a dict containing the config. Returns: dict: the complete simulation config file. """ content = Config(config).resolve() if "simulation" in content and "network" in content: simulation_path = content["simulation"] res = Config(str(simulation_path)).resolve() if "network" not in res: res["network"] = str(content["network"]) return res return content
def __init__(self, config): """Initializes a circuit object from a SONATA config file. Args: config (str/dict): Path to a SONATA config file or sonata config dict. Returns: Circuit: A Circuit object. """ self._config = Config(config).resolve()
def _resolve_config(filepath): """Resolve the config file if global ('network' and 'simulation' keys). Args: filepath (str): the path to the configuration file. Returns: dict: the complete simulation config file. """ filepath = Path(filepath) content = utils.load_json(str(filepath)) parent = filepath.parent if "simulation" in content and "network" in content: simulation_path = parent / content["simulation"] res = Config(str(simulation_path)).resolve() if "network" not in res: res["network"] = str(parent / content["network"]) return res return Config(str(filepath)).resolve()
def validate(config_file, bbp_check=False): """Validates Sonata circuit. Args: config_file (str): path to Sonata circuit config file bbp_check (bool): whether to check BBP spec. It's additional check. It does not replace any official checks. Returns: list: List of errors, empty if no errors """ config = Config(config_file).resolve() errors = _check_required_datasets(config) if not errors: errors = _check_populations(config) if not bbp_check: errors = [e for e in errors if not isinstance(e, BbpError)] _print_errors(errors) return set(errors)