aip_sdk.Adapter
aip_sdk.Adapter(data: dict[str, Any], sut_id: str, client: APIClient)
JSONPath-based adapter for mapping raw SUT response to GDI schema.
Attributes
idstr: Adapter IDconnection_idstr: Parent connection IDtemplate_namestr | None: Name of built-in template (if used)mapping_configdict[str, Any]: JSONPath mappings dictcreated_atdatetime | None: When this adapter was created
aip_sdk.Adapter.connection_id
aip_sdk.Adapter.connection_id: str = data['connection_id']
No docstring is defined in the source.
aip_sdk.Adapter.created_at
aip_sdk.Adapter.created_at: datetime | None = parse_dt(data['created_at'])
No docstring is defined in the source.
aip_sdk.Adapter.id
aip_sdk.Adapter.id: str = data['id']
No docstring is defined in the source.
aip_sdk.Adapter.mapping_config
aip_sdk.Adapter.mapping_config: dict[str, Any] = data.get('mapping_config', {})
No docstring is defined in the source.
aip_sdk.Adapter.template_name
aip_sdk.Adapter.template_name: str | None = data.get('template_name')
No docstring is defined in the source.
aip_sdk.Adapter.validate
aip_sdk.Adapter.validate(sample_payload: list[Any] | dict[str, Any]) -> AdapterValidateResult
Validate the adapter's JSONPath mappings against a sample SUT response.
Parameters
sample_payloadlist[Any] | dict[str, Any]: A raw SUT response to test mappings against, exactly as the endpoint returns it — including the top-level array a CV endpoint returns, which needs no wrapping
Returns
AdapterValidateResult: AdapterValidateResult with mapped output and any errors. A payload theAdapterValidateResult: connection's protocol cannot assemble comes back withvalidfalse andAdapterValidateResult: the reason inerrors, not as an exception.
Examples
>>> adapter = conn.get_adapter()
>>> sample = {"choices": [{"message": {"content": "Hello"}}]}
>>> result = adapter.validate(sample)
>>> if result.valid:
... print(f"Mapped output: {result.mapped}")
... else:
... print(f"Errors: {result.errors}")
A classification SUT returns its scores as a bare array:
>>> result = adapter.validate([{"label": "cat", "score": 0.9}, {"label": "dog", "score": 0.1}])
>>> print(result.mapped["predictions"])