Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tfx.components.infra_validator.model_server_runners.local_docker_runner.LocalDockerRunner

View source on GitHub

A model server runner that runs in a local docker runtime.

Inherits From: BaseModelServerRunner

tfx.components.infra_validator.model_server_runners.local_docker_runner.LocalDockerRunner(
    model, serving_binary, serving_spec
)

You need to pre-install docker in the machine that is running InfraValidator component. For that reason, it is recommended to use this runner only for testing purpose.

Args:

  • model: A model artifact to infra validate.
  • serving_binary: A ServingBinary to run.
  • serving_spec: A ServingSpec instance.

Methods

GetEndpoint

View source

GetEndpoint()

Get an endpoint to the model server to connect to.

Endpoint will be available after the model server job has reached the Running state.

Raises:

  • AssertionError: if runner hasn't reached the Running state.

Start

View source

Start()

Start the model server in non-blocking manner.

Start() will transition the job state from Initial to Scheduled. Serving platform will turn the job into Running state in the future.

In Start(), model server runner should prepare the resources model server requires including config files, environment variables, volumes, proper authentication, computing resource allocation, etc.. Cleanup for the resources does not happen automatically, and you should call Stop() to do that if you have ever called Start().

It is not allowed to run Start() twice. If you need to restart the job, you should create another model server runner instance.

Stop

View source

Stop()

Stop the model server in blocking manner.

Model server job would be gracefully stopped once infra validation logic is done. Here is the place you need to cleanup every resources you've created in the Start(). It is recommended not to raise error during the Stop() as it will usually be called in the finally block.

Stop() is always called if Start() is ever called, even if error has been raised during the Start() without completing it. Stop() implementation should take into account the case where Start() has not been called.

WaitUntilRunning

View source

WaitUntilRunning(
    deadline
)

Wait until model server job is running.

When this method is returned without error, the model server job is in the Running state where you can perform all the infra validation logic. It does not guarantee that model server job would remain in the Running state forever, (e.g. preemption could happen in some serving platform) and any kind of infra validation logic failure can be caused from model server job not being in the Running state. Still, it is a validation failure and we blame model for this.

Args:

  • deadline: A deadline time in UTC timestamp (in seconds).

Returns:

Whether the model is available or not.