App

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.

Factory Method

kubetorch.app(name: str | None = None, port: int | None = None, health_check: str | None = None, **kwargs: Dict)

Builds and deploys an instance of App.

Parameters:
  • 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

App Class

class kubetorch.App(compute: Compute, cli_command: str, pointers: tuple, name: str | None = None, run_async: bool = False)
__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)

property module_name

Name of the function or class.

deploy()

Deploy the app to the compute specified by the app arguments.