buildable
REQUIREMENTS_SUBSTITUTIONS module-attribute
Buildable
Buildable
is an abstract base class the encodes all the behavior needed to build a Chassis container.
Attributes:
Name | Type | Description |
---|---|---|
packaged |
| |
metadata | The metadata for the model. It is initialized with no values. | |
requirements | set[str] | A set of pip requirements needed by this model. |
apt_packages | set[str] | A set of |
additional_files | set[str] | A set of additional files required by the model at runtime. |
python_modules | dict | A dictionary of Python objects that will be serialized using |
merge_package
add_requirements
Declare a pip requirement for your model.
The value of each requirement can be anything supported by a line in a requirements.txt
file, including version constraints, etc.
All pip requirements declared via this method will be automatically installed when the container is built.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reqs | Union[str, list[str]] | Single python package (str) or list of python packages that are required dependencies to run the | required |
add_apt_packages
Add an OS package that will be installed via apt-get
.
If your model requires additional OS packages that are not part of the standard Python container, you can declare them here. Each package declared here will be apt-get install
'd when the container is built.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packages | Union[str, list] | Single OS-level package (str) or list of OS-level packages that are required dependencies to run the | required |
get_packaged_path
Convenience method for developers wanting to implement their own subclasses of Buildable. This method will return the final path in the built container of any additional files, etc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | str | The local path of a file. | required |
Returns:
Type | Description |
---|---|
str | The path the file will have in the final built container. |
verify_prerequisites
Raises an exception if the object is not yet ready for building.
Models require having a name, version, and at least one input and one output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options | BuildOptions | The | required |
prepare_context
Constructs the build context that will be used to build the container.
A build context is a directory containing a Dockerfile
and any other resources the Dockerfile
needs to build the container.
This method is called just before the build is initiated and compiles all the resources necessary to build the container. This includes the Dockerfile
, required Chassis library code, the server implementation indicated by the BuildOptions
, the cloudpickle'd model, the serialized model metadata, copies of any additional files, and a requirements.txt
.
Typically, you won't call this method directly, it will be called automatically by a Builder. The one instance where you might want to use this method directly is if you want to inspect the contents of the build context before sending it to a Builder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options | BuildOptions | The | DefaultBuildOptions |
Returns:
Type | Description |
---|---|
BuildContext | A |
render_dockerfile
Renders an appropriate Dockerfile
for this object with the supplied BuildOptions
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options | BuildOptions | The | required |
Returns:
Type | Description |
---|---|
str | A string containing the contents for a |