In the previous lesson, we covered the basics of running your Runpod serverless functions locally. Now, let’s explore some advanced options that give you more control over your local testing environment.
The Runpod Python SDK provides several command-line arguments that allow you to customize your local testing setup.
Let’s go through each of these options:
This argument allows you to set the verbosity of the console output. Options are:
ERROR
: Only show error messagesWARN
: Show warnings and errorsINFO
: Show general information, warnings, and errorsDEBUG
: Show all messages, including detailed debug informationExample:
The --rp_log_level
flag enables the Runpod debugger, which can help you troubleshoot issues in your code.
Example:
The following arguments allow you to configure the FastAPI server that simulates the Runpod serverless environment:
--rp_serve_api
: Starts the API server--rp_api_port
: Sets the port number (default is 8000)--rp_api_concurrency
: Sets the number of concurrent workers (default is 1)--rp_api_host
: Sets the hostname (default is “localhost”)Example:
This command starts the API server on port 8080 with 4 concurrent workers and makes it accessible from other devices on the network.
As we saw in the previous lesson, you can provide test input either through a JSON file or directly via the command line:
Example:
You can combine these arguments to create a highly customized local testing environment. Here’s an example that uses multiple options:
This command:
These advanced options for local testing with the Runpod Python SDK give you fine-grained control over your development environment. By mastering these tools, you can ensure your serverless functions are robust and ready for deployment to the Runpod cloud.
In the next lesson, we’ll explore how to structure more complex handlers to tackle advanced use cases in your serverless applications.