Skip to content

remote

RemoteBuilder

RemoteBuilder(url, package, options=DefaultBuildOptions, credentials=None, tls_verify=True)

Initializes a connection to a Chassis remote build server for a Buildable object (like ChassisModel).

A Docker context also be prepared according to the options supplied. The Docker context is a directory (in /tmp unless base_dir is given in options) containing a Dockerfile and all the resources necessary to build the container. For more information on how the context is prepared given the supplied options, see chassis.builder.Buildable.prepare_context.

Examples:

See chassis.builder.RemoteBuilder.build_image.

Parameters:

Name Type Description Default
url str

The URL to the Chassis remote build server. Example: "https://chassis.example.com:8443".

required
package Buildable

ChassisModel object that contains the code to be built.

required
options BuildOptions

Object that provides specific build configuration options. See chassis.builder.BuildOptions for more details.

DefaultBuildOptions
credentials Optional[str]

A string that will be used in the "Authorization" header.

None
tls_verify bool

Whether to enable TLS verification.

True

Raises:

Type Description
ValueError

if - the URL is not valid - the build server is not available - the build server is too old

build_image

build_image(name, tag='latest', timeout=3600, webhook=None, clean_context=True, block_until_complete=True)

Starts a remote build of the container. When finished, the built image will be pushed to the registry that the remote builder is configured for (see the Chassis remote build server Helm chart for configuration options) with the name and tag supplied as arguments.

By default, the build will be submitted with a timeout of one hour. You can change this value if desired. If the build takes longer than the timeout value, it will be canceled.

An optional webhook can be supplied as well. A webhook is a URL that will be called by the remote build server with the result of the build (see chassis.builder.BuildResponse).

Finally, at the end of this function, the Docker context that was created when the RemoteBuilder was initialized will be deleted by default. To prevent this, pass clean_context=False to this function.

Parameters:

Name Type Description Default
name str

Name of container image repository.

required
tag

Tag of container image.

'latest'
timeout int

Timeout value passed to build config object.

3600
webhook Optional[str]

A URL that will be called when the remote build finishes.

None
clean_context bool

If False does not remove build context folder.

True
block_until_complete bool

If True, will block until the job is complete. To get an immediate response and poll for build completion yourself, set to False.

True

Returns:

Type Description
BuildResponse

A BuildResponse object with details from the build job.

Raises:

Type Description
ValueError

If webhook is not valid URL

Example:

from chassisml import ChassisModel
from chassis.builder import RemoteBuilder, BuildOptions

model = ChassisModel(process_fn=predict)
model.metadata.model_name = "My Awesome Model"
model.metadata.model_version = "1.0.1"
model.metadata.add_input("input.txt", ["text/plain"])
model.metadata.add_output("results.json", "application/json")
options = BuildOptions(arch="arm64")
builder = RemoteBuilder("http://localhost:8080", model, options)
response = builder.build_image(name="chassis-model", tag="1.0.1")
print(response)

get_build_status

get_build_status(remote_build_id)

Checks the status of a remote build.

Parameters:

Name Type Description Default
remote_build_id str

Remote build identifier generated from [chassis.builder.RemoteBuilder.build_image].

required

Returns:

Type Description
BuildResponse

A BuildResponse object with details from the build job.

Example:

from chassisml import ChassisModel
from chassis.builder import RemoteBuilder, BuildOptions

model = ChassisModel(process_fn=predict)
model.metadata.model_name = "My Awesome Model"
model.metadata.model_version = "1.0.1"
model.metadata.add_input("input.txt", ["text/plain"])
model.metadata.add_output("results.json", "application/json")
options = BuildOptions(arch="arm64")
builder = RemoteBuilder("http://localhost:8080", model, options)
response = builder.build_image(name="chassis-model", tag="1.0.1", block_until_complete=False)
build_id = response.remote_build_id
print(builder.get_build_status(build_id))

get_build_logs

get_build_logs(remote_build_id)

Retrieves the logs from the remote build container.

Parameters:

Name Type Description Default
remote_build_id str

Remote build identifier generated from chassis.builder.RemoteBuilder.build_image.

required

Returns:

Type Description
str

The logs from the remote build container

Example:

from chassisml import ChassisModel
from chassis.builder import RemoteBuilder, BuildOptions

model = ChassisModel(process_fn=predict)
model.metadata.model_name = "My Awesome Model"
model.metadata.model_version = "1.0.1"
model.metadata.add_input("input.txt", ["text/plain"])
model.metadata.add_output("results.json", "application/json")
options = BuildOptions(arch="arm64")
builder = RemoteBuilder("http://localhost:8080", model, options)
response = builder.build_image(name="chassis-model", tag="1.0.1")
build_id = response.remote_build_id
print(builder.get_build_logs(build_id))

block_until_complete

block_until_complete(remote_build_id, timeout=None, poll_interval=5)

Blocks until Chassis remote build is complete or the timeout has been reached. Polls the Chassis job API until a result is marked as Completed or Failed.

Parameters:

Name Type Description Default
remote_build_id str

Remote build identifier generated from chassis.builder.RemoteBuilder.build_image.

required
timeout Optional[int]

Timeout threshold in seconds.

None
poll_interval int

Amount of time in seconds to wait in between API polls to check the build status.

5

Returns:

Type Description
BuildResponse

A BuildResponse object with details from the build job.

Example:

from chassisml import ChassisModel
from chassis.builder import RemoteBuilder, BuildOptions

model = ChassisModel(process_fn=predict)
model.metadata.model_name = "My Awesome Model"
model.metadata.model_version = "1.0.1"
model.metadata.add_input("input.txt", ["text/plain"])
model.metadata.add_output("results.json", "application/json")
options = BuildOptions(arch="arm64")
builder = RemoteBuilder("http://localhost:8080", model, options)
response = builder.build_image(name="chassis-model", tag="1.0.1", block_until_complete=False)
build_id = response.remote_build_id
response = builder.block_until_complete(build_id)
print(response)