ancient-wolf-19325
07/10/2024, 5:33 PMFlyteAdminClient to create and execute workflows. Here's a simplified example based on the provided data sources:
1. Setup FlyteAdminClient: Create a client to interact with the Flyte backend.
2. Define and Register Workflow: Define your workflow and register it with Flyte.
3. Trigger Workflow Execution: Use the client to trigger the workflow execution.
Here's an example in Scala:
import org.flyte.jflyte.FlyteAdminClient
import org.flyte.api.v1._
object FlyteWorkflowExample {
def main(args: Array[String]): Unit = {
// Initialize FlyteAdminClient
val client = FlyteAdminClient.create()
// Define your workflow (example)
val workflowId = WorkflowIdentifier.builder()
.project("flytesnacks")
.domain("development")
.name("example_workflow")
.build()
// Define inputs for the workflow
val inputs = LiteralMap.builder()
.literals(Map("input_name" -> Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofString("example_input")))))
.build()
// Trigger the workflow execution
val executionId = client.createExecution(
"flytesnacks",
"development",
ExecutionSpec.builder()
.launchPlan(LaunchPlanIdentifier.builder()
.project("flytesnacks")
.domain("development")
.name("example_workflow_launchplan")
.build())
.inputs(inputs)
.build()
)
// Print execution ID
println(s"Triggered workflow execution with ID: ${executionId.name()}")
}
}
This example demonstrates how to create a FlyteAdminClient, define a workflow, and trigger its execution programmatically.
Would you like more details or a more specific example?
Sources:
- FlyteKit Java Examples
- FlyteAdminClient
Slack Link
https://flyte-org.slack.com/archives/CP2HDHKE1/p1720632774.532009 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.