Search in sources :

Example 1 with BindingData

use of org.flyte.api.v1.BindingData in project flytekit-java by flyteorg.

the class IfBlockIdl method toOperand.

private static Operand toOperand(Map<String, Binding> extraInputs, SdkBindingData bindingData) {
    BindingData idl = bindingData.idl();
    if (idl.kind() == BindingData.Kind.PROMISE) {
        String nextVarName = "$" + extraInputs.size();
        extraInputs.put(nextVarName, Binding.builder().binding(idl).var_(nextVarName).build());
        return Operand.ofVar(nextVarName);
    } else {
        return Operand.ofPrimitive(bindingData.idl().scalar().primitive());
    }
}
Also used : BindingData(org.flyte.api.v1.BindingData)

Example 2 with BindingData

use of org.flyte.api.v1.BindingData in project flytekit-java by flyteorg.

the class SdkBindingData method ofStruct.

public static SdkBindingData ofStruct(SdkStruct struct) {
    BindingData bindingData = BindingData.ofScalar(Scalar.ofGeneric(struct.struct()));
    LiteralType literalType = LiteralType.ofSimpleType(SimpleType.STRUCT);
    return create(bindingData, literalType);
}
Also used : LiteralType(org.flyte.api.v1.LiteralType) BindingData(org.flyte.api.v1.BindingData)

Example 3 with BindingData

use of org.flyte.api.v1.BindingData in project flytekit-java by flyteorg.

the class ProtoUtilTest method provideArgsForShouldSerializeBindingData.

static Stream<Arguments> provideArgsForShouldSerializeBindingData() {
    BindingData apiScalar = BindingData.ofScalar(Scalar.ofPrimitive(Primitive.ofIntegerValue(1337L)));
    Literals.BindingData protoScalar = Literals.BindingData.newBuilder().setScalar(Literals.Scalar.newBuilder().setPrimitive(Literals.Primitive.newBuilder().setInteger(1337L).build()).build()).build();
    return Stream.of(Arguments.of(apiScalar, protoScalar), Arguments.of(BindingData.ofCollection(singletonList(apiScalar)), Literals.BindingData.newBuilder().setCollection(Literals.BindingDataCollection.newBuilder().addBindings(protoScalar).build()).build()), Arguments.of(BindingData.ofMap(singletonMap("foo", apiScalar)), Literals.BindingData.newBuilder().setMap(Literals.BindingDataMap.newBuilder().putBindings("foo", protoScalar).build()).build()), Arguments.of(BindingData.ofOutputReference(OutputReference.builder().nodeId("node-id").var("var").build()), Literals.BindingData.newBuilder().setPromise(Types.OutputReference.newBuilder().setNodeId("node-id").setVar("var").build()).build()));
}
Also used : Literals(flyteidl.core.Literals) BindingData(org.flyte.api.v1.BindingData)

Example 4 with BindingData

use of org.flyte.api.v1.BindingData in project flytekit-java by flyteorg.

the class SdkBindingData method ofPrimitive.

public static SdkBindingData ofPrimitive(Primitive primitive) {
    BindingData bindingData = BindingData.ofScalar(Scalar.ofPrimitive(primitive));
    LiteralType literalType = LiteralType.ofSimpleType(getSimpleType(primitive.kind()));
    return create(bindingData, literalType);
}
Also used : LiteralType(org.flyte.api.v1.LiteralType) BindingData(org.flyte.api.v1.BindingData)

Aggregations

BindingData (org.flyte.api.v1.BindingData)4 LiteralType (org.flyte.api.v1.LiteralType)2 Literals (flyteidl.core.Literals)1