<@U06RKAMK0UC> How do I run a workflow using java-...
# ask-ai
b
@ancient-wolf-19325 How do I run a workflow using java-flytekit?
a
To run a workflow using
java-flytekit
, you can use the
FlyteAdminClient
class from the
flytekit-java
library. Here’s a concise summary of the steps: 1. Define Workflow: Create your workflow and tasks using the
SdkWorkflow
and
SdkTask
classes. 2. Register Workflow: Use
jflyte
to register your workflow. 3. Trigger Execution: Utilize
FlyteAdminClient
to trigger the workflow execution. Here is an example of how you can trigger a workflow execution:
Copy code
import org.flyte.jflyte.FlyteAdminClient;
import org.flyte.api.v1.LiteralMap;
import org.flyte.api.v1.TaskIdentifier;
import org.flyte.api.v1.WorkflowExecutionIdentifier;

public class WorkflowExecutor {
    public static void main(String[] args) {
        FlyteAdminClient client = FlyteAdminClient.create();

        // Define the task identifier
        TaskIdentifier taskIdentifier = TaskIdentifier.builder()
                .domain("development")
                .project("my_project")
                .name("my_task")
                .version("v1")
                .build();

        // Define the input parameters
        LiteralMap inputs = LiteralMap.of(...); // Populate with your inputs

        // Trigger the workflow execution
        WorkflowExecutionIdentifier executionId = client.createExecution(
                "development",
                "my_project",
                "my_launch_plan",
                inputs
        );

        System.out.println("Workflow execution started with ID: " + executionId.name());
    }
}
Would you like more detail? Sources: - Flytekit-Java - Flyte Java Workflow Example πŸ‘ 0 button πŸ‘Ž 0 button πŸ’‘ Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 how do I run a workflow in Scala?
a
To run a workflow in Scala using Flyte, you can follow these steps: 1. Define Workflow and Tasks: Create your workflow and tasks using Scala. 2. Register Workflow: Use
jflyte
to register your workflow. 3. Trigger Execution: Utilize
FlyteAdminClient
to trigger the workflow execution. Here is an example of how you can trigger a workflow execution in Scala:
Copy code
import org.flyte.jflyte.FlyteAdminClient
import org.flyte.api.v1.{LiteralMap, TaskIdentifier, WorkflowExecutionIdentifier}

object WorkflowExecutor {
  def main(args: Array[String]): Unit = {
    val client = FlyteAdminClient.create()

    // Define the task identifier
    val taskIdentifier = TaskIdentifier.builder()
      .domain("development")
      .project("my_project")
      .name("my_task")
      .version("v1")
      .build()

    // Define the input parameters
    val inputs = LiteralMap.of(...) // Populate with your inputs

    // Trigger the workflow execution
    val executionId = client.createExecution(
      "development",
      "my_project",
      "my_launch_plan",
      inputs
    )

    println(s"Workflow execution started with ID: ${executionId.name()}")
  }
}
Would you like more detail? Sources: - Flytekit-Java - Flyte Java Workflow Example πŸ‘ 0 button πŸ‘Ž 1 button πŸ’‘ Hint: Mention @ancient-wolf-19325 in the thread for followups.
b
@ancient-wolf-19325 what package is the FlyteAdminClient in?
a
Sorry, there was a temporary error when processing your request. Please try again. If this problem persists, please contact support. πŸ‘ 0 button πŸ‘Ž 0 button πŸ’‘ Hint: Mention @runllm in the thread for followups.