tfx.components.InfraValidator

View source on GitHub

A TFX component to validate the model against the serving infrastructure.

Inherits From: BaseComponent

An infra validation is done by loading the model to the exactly same serving binary that is used in production, and additionaly sending some requests to the model server. Such requests can be specified from Examples artifact.

Examples

Full example using TensorFlowServing binary running on local docker.

infra_validator = InfraValidator(
    model=trainer.outputs['model'],
    examples=test_example_gen.outputs['examples'],
    serving_spec=ServingSpec(
        tensorflow_serving=TensorFlowServing(  # Using TF Serving.
            tags=['latest']
        ),
        local_docker=LocalDockerConfig(),  # Running on local docker.
    ),
    validation_spec=ValidationSpec(
        max_loading_time_seconds=60,
        num_tries=5,
    ),
    request_spec=RequestSpec(
        tensorflow_serving=TensorFlowServingRequestSpec(),
        num_examples=1,
    )
)

Minimal example when running on Kubernetes.

infra_validator = InfraValidator(
    model=trainer.outputs['model'],
    examples=test_example_gen.outputs['examples'],
    serving_spec=ServingSpec(
        tensorflow_serving=TensorFlowServing(
            tags=['latest']
        ),
        kubernetes=KubernetesConfig(),  # Running on Kubernetes.
    ),
)

<!-- Tabular view -->
 <table class="properties responsive orange">
<tr><th colspan="2"><h2 class="add-link">Args</h2></th></tr>

<tr>
<td>
`model`
</td>
<td>
A `Channel` of `ModelExportPath` type, usually produced by
[Trainer](https://www.tensorflow.org/tfx/guide/trainer) component.
_required_
</td>
</tr><tr>
<td>
`serving_spec`
</td>
<td>
A `ServingSpec` configuration about serving binary and
test platform config to launch model server for validation. _required_
</td>
</tr><tr>
<td>
`examples`
</td>
<td>
A `Channel` of `ExamplesPath` type, usually produced by
[ExampleGen](https://www.tensorflow.org/tfx/guide/examplegen) component.
If not specified, InfraValidator does not issue requests for validation.
</td>
</tr><tr>
<td>
`blessing`
</td>
<td>
Output `Channel` of `InfraBlessingPath` that contains the
validation result.
</td>
</tr><tr>
<td>
`request_spec`
</td>
<td>
Optional `RequestSpec` configuration about making requests
from `examples` input. If not specified, InfraValidator does not issue
requests for validation.
</td>
</tr><tr>
<td>
`validation_spec`
</td>
<td>
Optional `ValidationSpec` configuration.
</td>
</tr><tr>
<td>
`instance_name`
</td>
<td>
Optional name assigned to this specific instance of
InfraValidator.  Required only if multiple InfraValidator components are
declared in the same pipeline.
</td>
</tr><tr>
<td>
`enable_cache`
</td>
<td>
Optional boolean to indicate if cache is enabled for the
InfraValidator component. If not specified, defaults to the value
specified for pipeline's enable_cache parameter.
</td>
</tr>
</table>





<!-- Tabular view -->
 <table class="properties responsive orange">
<tr><th colspan="2"><h2 class="add-link">Attributes</h2></th></tr>

<tr>
<td>
`component_id`
</td>
<td>
DEPRECATED FUNCTION

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version.
Instructions for updating:
component_id is deprecated, use id instead
</td>
</tr><tr>
<td>
`component_type`
</td>
<td>
DEPRECATED FUNCTION

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version.
Instructions for updating:
component_type is deprecated, use type instead
</td>
</tr><tr>
<td>
`downstream_nodes`
</td>
<td>

</td>
</tr><tr>
<td>
`enable_cache`
</td>
<td>

</td>
</tr><tr>
<td>
`exec_properties`
</td>
<td>

</td>
</tr><tr>
<td>
`id`
</td>
<td>
Node id, unique across all TFX nodes in a pipeline.

If instance name is available, node_id will be:
<node_class_name>.<instance_name>
otherwise, node_id will be:
<node_class_name>
</td>
</tr><tr>
<td>
`inputs`
</td>
<td>

</td>
</tr><tr>
<td>
`outputs`
</td>
<td>

</td>
</tr><tr>
<td>
`type`
</td>
<td>

</td>
</tr><tr>
<td>
`upstream_nodes`
</td>
<td>

</td>
</tr>
</table>



## Child Classes
[`class DRIVER_CLASS`](../../tfx/components/InfraValidator/DRIVER_CLASS)

[`class SPEC_CLASS`](../../tfx/components/InfraValidator/SPEC_CLASS)

## Methods

<h3 id="add_downstream_node"><code>add_downstream_node</code></h3>

<a target="_blank" href="https://github.com/tensorflow/tfx/blob/v0.21.4/tfx/components/base/base_node.py#L163-L164">View source</a>

<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
<code>add_downstream_node(
    downstream_node
)
</code></pre>




<h3 id="add_upstream_node"><code>add_upstream_node</code></h3>

<a target="_blank" href="https://github.com/tensorflow/tfx/blob/v0.21.4/tfx/components/base/base_node.py#L156-L157">View source</a>

<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
<code>add_upstream_node(
    upstream_node
)
</code></pre>




<h3 id="from_json_dict"><code>from_json_dict</code></h3>

<a target="_blank" href="https://github.com/tensorflow/tfx/blob/v0.21.4/tfx/utils/json_utils.py#L74-L79">View source</a>

<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
<code>@classmethod</code>
<code>from_json_dict(
    dict_data: Dict[Text, Any]
) -> Any
</code></pre>

Convert from dictionary data to an object.


<h3 id="get_id"><code>get_id</code></h3>

<a target="_blank" href="https://github.com/tensorflow/tfx/blob/v0.21.4/tfx/components/base/base_node.py#L55-L76">View source</a>

<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
<code>@classmethod</code>
<code>get_id(
    instance_name: Optional[Text] = None
)
</code></pre>

Gets the id of a node.

This can be used during pipeline authoring time. For example:
from tfx.components import Trainer

resolver = ResolverNode(..., model=Channel(
    type=Model, producer_component_id=Trainer.get_id('my_trainer')))

<!-- Tabular view -->
 <table class="properties responsive orange">
<tr><th colspan="2">Args</th></tr>

<tr>
<td>
`instance_name`
</td>
<td>
(Optional) instance name of a node. If given, the instance
name will be taken into consideration when generating the id.
</td>
</tr>
</table>



<!-- Tabular view -->
 <table class="properties responsive orange">
<tr><th colspan="2">Returns</th></tr>
<tr class="alt">
<td colspan="3">
an id for the node.
</td>
</tr>

</table>



<h3 id="to_json_dict"><code>to_json_dict</code></h3>

<a target="_blank" href="https://github.com/tensorflow/tfx/blob/v0.21.4/tfx/components/base/base_node.py#L98-L102">View source</a>

<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link">
<code>to_json_dict() -> Dict[Text, Any]
</code></pre>

Convert from an object to a JSON serializable dictionary.




## Class Variables

* `EXECUTOR_SPEC` <a id="EXECUTOR_SPEC"></a>