Executing a WfRun
Now that you've created your first WfSpec
, let's explore the different ways to run it. LittleHorse provides multiple methods to execute WfRun
s, each suited for different use cases.
This tutorial assumes you have completed the Your First WfSpec
guide.
Executing with lhctl
The simplest way to execute a WfRun
is using the command-line interface. The lhctl
command provides a quick way to execute and monitor WfRun
s:
# Execute a `WfRun` with a name parameter
lhctl run quickstart name Obi-Wan
You'll see output like:
{
"id": {
"id": "69881bf9aaf84c2f84bdde7ceb2dd105"
},
"wfSpecId": {
"name": "quickstart",
"majorVersion": 0,
"revision": 0
},
"oldWfSpecVersions": [],
"status": "RUNNING",
"greatestThreadrunNumber": 0,
"startTime": "2025-01-07T01:53:47.212Z",
"threadRuns": [
{
"wfSpecId": {
"name": "quickstart",
"majorVersion": 0,
"revision": 0
},
"number": 0,
"status": "RUNNING",
"threadSpecName": "entrypoint",
"startTime": "2025-01-07T01:53:47.296Z",
"childThreadIds": [],
"haltReasons": [],
"currentNodePosition": 1,
"handledFailedChildren": [],
"type": "ENTRYPOINT"
}
],
"pendingInterrupts": [],
"pendingFailures": []
}
The lhctl
command is perfect for development and testing scenarios. It's also commonly used in CI/CD pipelines for automation.
Executing from the Dashboard
LittleHorse provides a visual interface for running and monitoring WfRun
s:
- Navigate to
http://localhost:8080
in your browser - Click on the "quickstart"
WfSpec
- Click "Execute"
- Enter "Obi-Wan" in the name field
- Click "Execute Workflow"

The dashboard will show you the WfRun
's execution status in real-time, making it ideal for debugging.
Executing with the LittleHorse SDK
For production applications, you'll typically want to execute a WfRun
programmatically. Create a new file called RunWorkflow.java
:
- Java
- Python
- Go
- C#
package io.littlehorse.quickstart;
import io.littlehorse.sdk.common.LHLibUtil;
import io.littlehorse.sdk.common.config.LHConfig;
import io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseBlockingStub;
import io.littlehorse.sdk.common.proto.RunWfRequest;
import io.littlehorse.sdk.common.proto.WfRun;
public class Main {
static LHConfig config = new LHConfig();
public static void main(String[] args) {
LittleHorseBlockingStub client = config.getBlockingStub();
WfRun result = client.runWf(RunWfRequest.newBuilder()
.setWfSpecName("quickstart")
.putVariables("input-name", LHLibUtil.objToVarVal("Obi-Wan Kenobi"))
.build());
System.out.println(result);
}
}
import littlehorse
from littlehorse.config import LHConfig
from littlehorse.model import RunWfRequest
config = LHConfig()
client = config.stub()
result = client.RunWf(RunWfRequest(
wf_spec_name="quickstart",
variables={
"input-name": littlehorse.to_variable_value("Obi-Wan Kenobi"),
}
))
print(result)
package main
import (
"context"
"github.com/littlehorse-enterprises/littlehorse/sdk-go/lhproto"
"github.com/littlehorse-enterprises/littlehorse/sdk-go/littlehorse"
)
func main() {
config := littlehorse.NewConfigFromEnv()
client, _ := (config).GetGrpcClient()
inputName, _ := littlehorse.InterfaceToVarVal("Obi-Wan Kenobi")
result, _ := (*client).RunWf(context.Background(), &lhproto.RunWfRequest{
WfSpecName: "quickstart",
Variables: map[string]*lhproto.VariableValue{
"input-name": inputName,
},
})
littlehorse.PrintProto(result)
}
using QuickStart;
using LittleHorse.Sdk;
using LittleHorse.Sdk.Helper;
using LittleHorse.Sdk.Common.Proto;
public class Program
{
static LHConfig config = new LHConfig();
public static void Main(string[] args)
{
var client = config.GetGrpcClientInstance();
var result = client.RunWf(new RunWfRequest {
WfSpecName = "quickstart",
Variables = { { "input-name", LHMappingHelper.ObjectToVariableValue("Obi-Wan Kenobi") } }
});
Console.WriteLine(result);
}
}
The SDK provides the most flexibility for executing a WfRun
. You can integrate it into your existing applications and handle WfRun
execution programmatically.
Choosing the Right Method
Each method has its ideal use case:
Method | Best For |
---|---|
lhctl | Development, testing, and CI/CD pipelines |
Dashboard | Debugging, monitoring, and team collaboration |
SDK | Production applications and system integration |
Remember, all methods interact with the same LittleHorse server, so you can mix and match them based on your needs.
Wrapping Up
You've learned how to execute a WfRun
using different methods and monitor its execution. In the next lesson, we'll dive deeper into debugging WfRun
s and handling errors.
If you haven't already:
- Join the LittleHorse Slack Community
- Give us a star on GitHub
- Check out our documentation