Local Testing

Serverless Testing

It is important to test your serverless workers locally (or on GPU-Cloud) before deploying them to RunPod's serverless platform. This will help you catch errors early and avoid wasting expensive resources. This guide will show you how to test your serverless workers.

If any errors are returned by the worker while running a test_input job the worker will exit with a non-zero exit code. Otherwise the worker will exit with a zero exit code. This can be used to check if the worker ran successfully, for example in a CI/CD pipeline.

Test Input File

To test your serverless worker locally, create the file test_input.json in the root directory of your project. This file will be used to test your worker locally.

  "input": {
    "your_model_input_key": "your_model_input_value"

Then run the python file which contains your worker handler, it will be called with the contents of test_input.json as the input.

Test Input Argument

The second method of testing your serverless worker locally is to pass the input as an argument to the python file which contains your worker handler.

python your_handler.py --test_input '{"input": {"your_model_input_key": "your_model_input_value"}}'