espnet3.contract.inference.load_inference_contract
Less than 1 minute
espnet3.contract.inference.load_inference_contract
espnet3.contract.inference.load_inference_contract(config: DictConfig | Mapping[str, Any] | None, , allow_imports: bool = True) → InferenceContract | None
Build a contract from the inference config after loading custom kinds.
- Parameters:
- config – The
contractsection: a mapping (orDictConfig) withinputs,outputsand optionalimports;Nonefor none. - allow_imports – Whether
importsmay be loaded;Falsefor an untrusted bundle.
- config – The
- Returns: The contract, or
NonewhenconfigisNone. - Raises:
- TypeError – If
configorimportshas the wrong type. - ValueError – If the contract has an unknown option, or
importsis set whileallow_importsis false.
- TypeError – If
Examples
>>> contract = load_inference_contract(
... {
... "inputs": {"text": {"kind": "text"}},
... "outputs": {"text": {"kind": "text"}},
... }
... )
>>> [field.name for field in contract.inputs]
['text']