I'm trying to import the `FlyteAdminClient` into a...
# flytekit-java
b
I'm trying to import the
FlyteAdminClient
into a Scala project, but it doesn't seem to live in the
import org.flyte.jflyte.FlyteAdminClient
as per the examples. I'm likely missing a dependency somewhere?
I'm looking for a current example of running a workflow from Scala code.
@brief-window-55364 do you know if something like ⬆️ actually exists?
I found some examples via the
ask-ai
machinery, but they don't seem current.
I'm trying to do this portion in Scala.
does this work
import org.flyte.jflyte.utils.FlyteAdminClient;
b
Yeah, just found that but the signature is completely different.
Copy code
public static FlyteAdminClient create(String target, boolean insecure, @Nullable TokenSource tokenSource)
This is pretty frustrating. I'm really wondering about the Java/Scala SDK. If I'm being completely honest, it doesn't seem like it's a viable interface to Flyte. I thought that, given it's listed on the main page of the documentation, it'd be at least somewhat approachable for the base features. While I can define/register tasks, workflows, launch plans using
jflyte
, there seems to be no way (at least no documented way) to actually engage with them, e.g. execute a workflow, get a workflow status, get a workflow result, etc. Again, the first page the the documentation naively suggests the Java/Scala support is first-class. If I'm honest, that's nowhere near true... unless I'm completely missing something here. Maybe I should figure out how to generate the code from the IDL/protobufs and abandon this library altogether. I'm also happy to contribute to the docs if that's all that's missing. Happy to take some advice here as I'm sure others have gone through this and might be able to point me in the right direction.
a
so you've got the workflow registered and just need to execute it now?
We implemented out our FlyteAdminClient off of the proto files here - https://buf.build/flyteorg/flyteidl/docs/main:flyteidl.service
b
so you've got the workflow registered and just need to execute it now?
Yes, I was able to get them registered.
It has two create methods...
create
and
idempotentCreate
a
well, it looks like the
create
is to create your instance of the client and then actually you want to call
creaetExecution(...)
and point to your default launch plan for the workflow you created
sorry, needed to look at the code for a minute to see what it's doing
b
Doing the same, reading code to see what I need to provide to the
create
function.
a
create("dns:///flyteadmin.default.svc.cluster.local:8089", false, null)
is my guess
(assumes port and k8s)
b
I'm running the demo container, i.e.
flytectl demo start
Copy code
admin:
  # For GRPC endpoints you might want to use dns:///flyte.myexample.com
  endpoint: localhost:30080
  insecure: true
# This is not a needed configuration, only useful if you want to explore the data in sandbox. For non sandbox, please
# do not use this configuration, instead prefer to use aws, gcs, azure sessions. Flytekit, should use fsspec to
# auto select the right backend to pull data as long as the sessions are configured. For Sandbox, this is special, as
# minio is s3 compatible and we ship with minio in sandbox.
storage:
  connection:
    endpoint: <http://localhost:30002>
    access-key: minio
    secret-key: miniostorage
I'm surprised
createExecution
doesn't return an execution id
and it's package private, so I can't call it
I've pivoted and successfully generated the code from the IDL - I now need to root around the API to see how this all works
@alert-oil-1341 if you have a few examples of executing workflows via code generated from the IDL, that's be awesome.
a
I think this is a basic example
Copy code
public CompletableFuture<ExecutionCreateResponse> createExecution(
        final String domain,
        final String project,
        final String name,
        final String version,
        final LiteralMap input) {

        return toCompletableFuture(
            stub.createExecution(
                ExecutionCreateRequest.newBuilder()
                    .setDomain(domain)
                    .setProject(project)
                    .setInputs(input)
                    .setSpec(
                        ExecutionSpec.newBuilder()
                            .setLaunchPlan(
                                Identifier.newBuilder()
                                    .setResourceType(ResourceType.LAUNCH_PLAN)
                                    .setDomain(domain)
                                    .setProject(project)
                                    .setName(name)
                                    .setVersion(version)
                                    .build())
                            .build())
                    .build()))
        .exceptionally(handleFlyteExceptions());
    }
b
what is the
stub
in this case?
a
grpc futures stub
private AdminServiceGrpc.AdminServiceFutureStub stub;
b
alright... I'm able to list projects
now just struggling with inputs a bit
h
@bumpy-match-83743, can you expand a bit on this issue you're seeing with inputs?