targon run
The targon run command allows you to execute a function from a Targon application locally, within the Targon runtime context. This is useful for testing and debugging your functions before deploying them.
targon run <FUNCTION_REFERENCE> [OPTIONS]
Arguments
FUNCTION_REFERENCE: A reference to the Targon application object containing the function you want to run, specified in the formatpath.to.file:app_object_name.
Dynamic Options
The targon run command dynamically generates CLI options based on the signature of the target function you are trying to run. For each argument in your function, a corresponding command-line option is created.
For example, consider a function with the following signature in your main.py file:
@app.local_entrypoint()
def process_data(name: str, age: int, is_active: bool = False):
...
When you run targon run main.py:app, the CLI will provide the following options:
targon run main.py:app --name "John Doe" --age 30 --is-active
- Arguments are converted to
--kebab-case. - The types are inferred from the function's type hints (
str,int,bool, etc.). - Arguments with default values are optional.
boolflags are created as--flag/--no-flag.- If the function doesn't have a
local_entrypoint,targon runwill execute the first available function in the application.