Hello World
You can test that your system is configured correctly by dispatching a minimal "hello world" script that runs on your remote Kubernetes cluster.
import kubetorch as kt def hello_world(num_prints = 1): for print_num in range(num_prints): print('Hello world ', print_num) if __name__ == "__main__": compute = kt.Compute(cpus = 1) remote_hello = kt.fn(hello_world).to(compute) results = remote_hello(5)
Run kt list
via the Kubetorch CLI to view a list of all the services that have been dispatched
to your cluster. You should see a service named helloworld
.
To more thoroughly test, try importing your own function or class and use a custom Docker image. We recommend running this script from inside the same git repo or package as the imported module, though it's possible to sync local modules from outside the current repo.
import kubetorch as kt from my_package.my_module import my_function if __name__ == "__main__": compute = kt.Compute(cpus = 1, image=kt.Image(image_id="my_registry.com/my_image:my_tag")) remote_fn = kt.fn(my_function).to(compute) results = remote_fn(args)