def inject_contracts(self, skill: Skill) -> None: if skill.config.contracts is not None: # check all contracts are present contracts = {} # type: Dict[str, Contract] for contract_id in skill.config.contracts: contract = self._contract_registry.fetch(contract_id) if contract is None: raise ValueError( "Missing contract for contract id {}".format(contract_id) ) contracts[contract_id.name] = contract skill.inject_contracts(contracts)
def inject_contracts(self, skill: Skill) -> None: """ Inject contracts into a skill context. :param skill: a skill :return: None """ if skill.config.contracts is not None: # check all contracts are present contracts = {} # type: Dict[str, Contract] for contract_id in skill.config.contracts: contract = self._component_registry.fetch( ComponentId(ComponentType.CONTRACT, contract_id)) if contract is None: raise ValueError( "Missing contract for contract id {}".format( contract_id)) contracts[contract_id.name] = cast(Contract, contract) skill.inject_contracts(contracts)