def _read_addresses(self): with open("./autonomous_hegician/aea-config.yaml", "r") as f: return { k: v for k, v in yaml_load_all(f)[1]["models"]["strategy"] ["args"].items() if k != "ledger_id" }
def test_yaml_dump_all_load_all(): """Test yaml_dump_all and yaml_load_all.""" f = io.StringIO() data = [{"a": "12"}, {"b": "13"}] yaml_dump_all(data, f) f.seek(0) assert yaml_load_all(f) == data
def update_ah_config_with_new_config( addresses, file_path: str = "./autonomous_hegician/aea-config.yaml"): """Get the AH config and update it with contract addresses.""" with open(file_path, "r") as fp: full_config: List[Dict[str, Any]] = yaml_load_all(fp) assert len(full_config) >= 2, "Expecting at least one override defined!" skill_config = full_config[1] assert skill_config["public_id"] == "eightballer/option_management:0.1.0" skill_config["models"]["strategy"]["args"] = OrderedDict(addresses) full_config_updated = [full_config[0], skill_config] + full_config[2:] with open(file_path, "w") as fp: print(full_config_updated) yaml_dump_all(full_config_updated, fp)
def test_agent_configuration_dump_multipage(): """Test agent configuration dump with component configuration.""" loader = ConfigLoaders.from_package_type(PackageType.AGENT) agent_config = loader.load( Path(CUR_PATH, "data", "aea-config.example_multipage.yaml").open()) # test main agent configuration loaded correctly assert agent_config.agent_name == "myagent" assert agent_config.author == "fetchai" # test component configurations loaded correctly assert len(agent_config.component_configurations) == 1 fp = io.StringIO() loader.dump(agent_config, fp) fp.seek(0) agent_config = yaml_load_all(fp) assert agent_config[0]["agent_name"] == "myagent" assert agent_config[1]["public_id"] == "dummy_author/dummy:0.1.0" assert agent_config[1]["type"] == "skill"
def update_ah_config_with_new_config( ledger_string, file_paths: Tuple[str, ...] = ( "./autonomous_hegician/aea-config.yaml", "./hegic_deployer/aea-config.yaml", ), ): """Get the AH config and update it with ledger string.""" for file_path in file_paths: with open(file_path, "r") as fp: full_config: List[Dict[str, Any]] = yaml_load_all(fp) assert len(full_config) >= 3, "Expecting at least two overrides defined!" connection_config = full_config[2] assert connection_config["public_id"] == "fetchai/ledger:0.9.0" connection_config["config"]["ledger_apis"]["ethereum"][ "address" ] = ledger_string full_config_updated = full_config[:2] + [connection_config] + full_config[3:] with open(file_path, "w") as fp: yaml_dump_all(full_config_updated, fp)
def _load_config_data(cls, aea_project_path: Path) -> List[Dict]: with open_file( cls._get_agent_config_file_path(aea_project_path)) as fp: data = yaml_load_all(fp) return data
def _load_agent_config(self, file_pointer: TextIO) -> AgentConfig: """Load an agent configuration.""" configuration_file_jsons = yaml_load_all(file_pointer) return self.load_agent_config_from_json(configuration_file_jsons)
def test_from_json(self): """Test load project from json file with path specified.""" with open(Path(self._get_cwd(), DEFAULT_AEA_CONFIG_FILE), "r") as fp: json_config = yaml_load_all(fp) AEABuilder.from_config_json(json_config, Path(self._get_cwd()))