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.
Examples:
Define the kt.app object and compute in your Python file:
import kubetorch as kt # 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") if __name__ == "__main__": ...
Deploy and run the app remotely using the kt run CLI command:
kt run python train.py --epochs 5 kt run fastapi run my_app.py --name fastapi-app
- __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()in conjunction with the kt run CLI command.
- 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.