tesseract
Python API¶
- class tesseract_core.Tesseract(url)[source]¶
A Tesseract.
This class represents a single Tesseract instance, either remote or local, and provides methods to run commands on it and retrieve results.
Communication between a Tesseract and this class is done either via HTTP requests or docker exec invocations (only possible for local instances spawned when instantiating the class).
- property available_endpoints: list[str]¶
Get the list of available endpoints.
- Returns:
a list with all available endpoints for this Tesseract.
- property input_schema: dict¶
Get the input schema of this Tessseract.
- Returns:
dictionary with the input schema.
- jacobian(inputs, jac_inputs, jac_outputs)[source]¶
Calculate the Jacobian of (some of the) outputs w.r.t. (some of the) inputs.
- jacobian_vector_product(inputs, jvp_inputs, jvp_outputs, tangent_vector)[source]¶
Calculate the Jacobian Vector Product (JVP) of (some of the) outputs w.r.t. (some of the) inputs.
- Parameters:
- Return type:
- Returns:
dictionary with the results.
- property openapi_schema: dict¶
Get the OpenAPI schema of this Tessseract.
- Returns:
dictionary with the OpenAPI Schema.
- property output_schema: dict¶
Get the output schema of this Tessseract.
- Returns:
dictionary with the output schema.
- tesseract_core.build_tesseract(src_dir, image_tag, build_dir=None, inject_ssh=False, config_override=(), keep_build_cache=False, generate_only=False)[source]¶
Build a new Tesseract from a context directory.
- Parameters:
src_dir (
Path
) – path to the Tesseract project directory, where the tesseract_api.py and tesseract_config.yaml files are located.image_tag (
str
|None
) – name to be used as a tag for the Tesseract image.build_dir (
Path
|None
) – directory to be used to store the build context. If not provided, a temporary directory will be created.inject_ssh (
bool
) – whether or not to forward SSH agent when building the image.config_override (
tuple
[tuple
[list
[str
],str
],...
]) – overrides for configuration options in the Tesseract.keep_build_cache (
bool
) – whether or not to keep the Docker build cache.generate_only (
bool
) – only generate the build context but do not build the image.
- Return type:
Image
|Path
- Returns:
docker.models.images.Image representing the built Tesseract image, or path to build directory if generate_only is True.
- tesseract_core.run_tesseract(image, command, args, volumes=None, gpus=None)[source]¶
Start a Tesseract and execute a given command.
- Parameters:
image (
str
|Image
) – string or docker.models.images.Image object of the Tesseract to run.command (
str
) – Tesseract command to run, e.g. apply.volumes (
list
[str
] |None
) – list of paths to mount in the Tesseract container.gpus (
list
[int
|str
] |None
) – list of GPUs, as indices or names, to passthrough the container.
- Return type:
- Returns:
Tuple with the stdout and stderr of the Tesseract.
- tesseract_core.serve(images, port='', volumes=None, gpus=None)[source]¶
Serve one or more Tesseract images.
Start the Tesseracts listening on an available ports on the host.
- Parameters:
images (
list
[str
|Image
]) – a list of Tesseract image IDs as strings or docker’s Image object.port (
str
) – port or port range to serve the tesseract on.volumes (
list
[str
] |None
) – list of paths to mount in the Tesseract container.gpus (
list
[str
] |None
) – IDs of host Nvidia GPUs to make available to the Tesseracts.
- Return type:
- Returns:
A string representing the Tesseract Project ID.