New RunLLM response generated: >>>*# Question* So...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* So I have the demo workflows running against the remote sandbox environment. I now need to transition to getting JVM workflows running. I want to create a simple workflow using the Scala SDK (part of java-flytekit), all in code, with no CLI in the picture. I see the demos have examples of a workflow, but it's not clear to me how to trigger a workflow in code. Can someone point me to it? # Answer To trigger a Flyte workflow in code using the Scala SDK, you can follow the example provided in the Flyte documentation for the Java SDK. You need to use the
FlyteAdminClient
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:
Copy code
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.