bumpy-match-83743
07/23/2024, 9:22 PMancient-wolf-19325
07/23/2024, 9:22 PMsync_execution
method from the FlyteRemote
class in flytekit
. This method will synchronize the state of the workflow execution and provide detailed information about its status.
Here's a concise example:
import flytekit
from flytekit.remote import FlyteRemote
# Initialize FlyteRemote with your configuration
config = flytekit.configuration.Config.auto("config.yml")
remote = FlyteRemote(config)
# Fetch the workflow execution
execution = remote.fetch_execution(project="my_project", domain="my_domain", name="execution_name")
# Sync the execution to get the latest status
execution = remote.sync_execution(execution, sync_nodes=True)
# Check the status
print(f"Workflow execution status: {execution.closure.phase}")
This code will print the current status of the workflow execution, such as RUNNING
, SUCCEEDED
, or FAILED
.
Would you like more details?
Sources:
- FlyteCTL Feature
- Flyte Community Discussion 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.bumpy-match-83743
07/23/2024, 9:23 PMancient-wolf-19325
07/23/2024, 9:23 PMGetExecution
and ListNodeExecutions
methods from the AdminService
in Flyte's gRPC API.
1. GetExecution: Fetches the details of a specific workflow execution.
2. ListNodeExecutions: Lists all node executions for a given workflow execution, which can be used to get detailed status information about each node within the workflow.
Here is a concise example of how you might use these methods:
import (
"context"
"log"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"google.golang.org/grpc"
)
func main() {
conn, err := grpc.Dial("flyte-admin-service:80", grpc.WithInsecure())
if err != nil {
log.Fatalf("Failed to connect to Flyte Admin service: %v", err)
}
defer conn.Close()
client := admin.NewAdminServiceClient(conn)
// Fetch the workflow execution
executionRequest := &admin.WorkflowExecutionGetRequest{
Id: &admin.WorkflowExecutionIdentifier{
Project: "my_project",
Domain: "my_domain",
Name: "execution_name",
},
}
execution, err := client.GetExecution(context.Background(), executionRequest)
if err != nil {
log.Fatalf("Failed to get execution: %v", err)
}
log.Printf("Workflow execution status: %v", execution.Closure.Phase)
// List node executions
nodeExecutionListRequest := &admin.NodeExecutionListRequest{
WorkflowExecutionId: executionRequest.Id,
}
nodeExecutions, err := client.ListNodeExecutions(context.Background(), nodeExecutionListRequest)
if err != nil {
log.Fatalf("Failed to list node executions: %v", err)
}
for _, nodeExecution := range nodeExecutions.NodeExecutions {
log.Printf("Node execution: %v, Status: %v", nodeExecution.Id.NodeId, nodeExecution.Closure.Phase)
}
}
Would you like more details?
Sources:
- flyteidl/service/admin_grpc.pb.go
- flyteidl/service/admin.pb.go 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.bumpy-match-83743
07/23/2024, 9:31 PMancient-wolf-19325
07/23/2024, 9:31 PMGetExecution
method from the AdminService
. This method retrieves the details of a specific workflow execution, including its current status.
Here's a concise example in Go:
import (
"context"
"log"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"google.golang.org/grpc"
)
func main() {
conn, err := grpc.Dial("flyte-admin-service:80", grpc.WithInsecure())
if err != nil {
log.Fatalf("Failed to connect to Flyte Admin service: %v", err)
}
defer conn.Close()
client := admin.NewAdminServiceClient(conn)
// Fetch the workflow execution
executionRequest := &admin.WorkflowExecutionGetRequest{
Id: &admin.WorkflowExecutionIdentifier{
Project: "my_project",
Domain: "my_domain",
Name: "execution_name",
},
}
execution, err := client.GetExecution(context.Background(), executionRequest)
if err != nil {
log.Fatalf("Failed to get execution: %v", err)
}
// Check if the workflow execution has completed
if execution.Closure.Phase == admin.WorkflowExecution_SUCCEEDED ||
execution.Closure.Phase == admin.WorkflowExecution_FAILED ||
execution.Closure.Phase == admin.WorkflowExecution_ABORTED {
log.Printf("Workflow execution has completed with status: %v", execution.Closure.Phase)
} else {
log.Printf("Workflow execution is still in progress with status: %v", execution.Closure.Phase)
}
}
This code connects to the Flyte Admin service, fetches the workflow execution details, and checks if the execution has completed by examining the Phase
field in the Closure
of the execution.
Would you like more details?
Sources:
- flyteidl/service/admin_grpc.pb.go
- flyteidl/service/admin.pb.go 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.