tfx.v1.components.InfraValidator

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

Inherits From: BaseComponent, BaseNode

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.
    ),
)

Component outputs contains:

See the InfraValidator guide for more details.

model A BaseChannel of ModelExportPath type, usually produced by Trainer component. required
serving_spec A ServingSpec configuration about serving binary and test platform config to launch model server for validation. required
examples A BaseChannel of ExamplesPath type, usually produced by ExampleGen component. If not specified, InfraValidator does not issue requests for validation.
request_spec Optional RequestSpec configuration about making requests from examples input. If not specified, InfraValidator does not issue requests for validation.
validation_spec Optional ValidationSpec configuration.

outputs Component's output channel dict.

Methods

with_node_execution_options

POST_EXECUTABLE_SPEC None
PRE_EXECUTABLE_SPEC None