When developing Runpod Serverless functions, it’s crucial to test them thoroughly before deployment. The Runpod SDK provides a powerful local testing environment that allows you to simulate your Serverless endpoints right on your development machine. This local server eliminates the need for constant Docker container rebuilds, uploads, and endpoint updates during the development and testing phase.
To facilitate this local testing environment, the Runpod SDK offers a variety of flags that allow you to customize your setup. These flags enable you to:
By using these flags, you can create a local environment that closely mimics the behavior of your functions in the Runpod cloud, allowing for more accurate testing and smoother deployments.
This guide provides a comprehensive overview of all available flags, their purposes, and how to use them effectively in your local testing workflow.
To start your local server with additional flags, use the following format:
Replace your_function.py
with the name of your Python file containing the Runpod handler.
Starts the API server for local testing.
Usage:
Sets the port number for the FastAPI server.
Default: 8000
Usage:
Setting --rp_api_host
to 0.0.0.0
allows connections from other devices on the network, which can be useful for testing but may have security implications.
Sets the number of concurrent workers for the FastAPI server.
Default: 1
Usage:
When using --rp_api_concurrency
with a value greater than 1, ensure your main file is named main.py
for proper FastAPI integration.
Sets the hostname for the FastAPI server.
Default: “localhost”
Usage:
Controls the verbosity of console output.
Options: ERROR
| WARN
| INFO
| DEBUG
Usage:
Enables the Runpod debugger for troubleshooting. The --rp_debugger
flag is particularly useful when you need to step through your code for troubleshooting.
Usage:
Provides test input data for your function, formatted as JSON.
Usage:
The --test_input
flag is an alternative to using a test_input.json
file. If both are present, the command-line input takes precedence.
You can combine multiple flags to customize your local testing environment.
For example:
This command starts the local server on port 8080
with 4 concurrent workers, sets the log level to DEBUG
, and provides test input data.
These flags provide powerful tools for customizing your local testing environment. By using them effectively, you can simulate various scenarios, debug issues, and ensure your Serverless functions are robust and ready for deployment to the Runpod cloud.
For more detailed information on each flag and advanced usage scenarios, refer to the individual tutorials in this documentation.