The App
class wraps a Python CLI command. It syncs over the file and any necessary requirements to the specified
compute, where it runs your file remotely. The file can be any Python file: a basic training script, a script that
uses kubetorch to deploy further services, or a FastAPI app.
Builds and deploys an instance of App
.
name (str, optional) – Name to give the remote app. If not provided, will be based off the name of the file in which the app was defined.
port (int, optional) – Server port to expose, if the app starts an HTTP server.
health_check (str, optional) – Health check endpoint, if running a server, to check when server is up and ready.
**kwargs – Compute kwargs, to define the compute on which to run the app on.
Example
>>> # Define the app at the top of the Python file to deploy >>> # train.py >>> kt.app(name="my-app", image=kt.Image("docker-latest"), cpus="0.01")
>>> # Use kt run CLI command to build and deploy the app >>> kt run python train.py --epochs 5
- __init__(compute: Compute, cli_command: str, pointers: tuple, name: str | None = None, run_async: bool = False)
Initialize an App object for remote execution.
Note
To create an App, please use the factory method
app()
.
- Parameters:
compute (Compute) – Compute
cli_command (str) – CLI command to run on the compute.
pointers (tuple) – A tuple containing references needed to locate the app file, of the format (current working directory, path of file relative to cwd, None)
name (str, optional) – Name to assign the app. If not provided, will be based on the name of the file in which the app was defined.
run_async (bool, optional) – Whether to run the app async. (Default:
False
)
Name of the function or class.
Deploy the app to the compute specified by the app arguments.