Search in sources :

Example 1 with PartialLaunchPlanIdentifier

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

the class ProtoUtilTest method shouldSerializeWorkflowNodeForLaunchPlanRef.

@Test
void shouldSerializeWorkflowNodeForLaunchPlanRef() {
    PartialLaunchPlanIdentifier launchPlanRef = PartialLaunchPlanIdentifier.builder().domain("domain").project("project").name("name").version("version").build();
    WorkflowNode workflowNode = WorkflowNode.builder().reference(WorkflowNode.Reference.ofLaunchPlanRef(launchPlanRef)).build();
    assertThat(ProtoUtil.serialize(workflowNode), equalTo(Workflow.WorkflowNode.newBuilder().setLaunchplanRef(IdentifierOuterClass.Identifier.newBuilder().setResourceType(LAUNCH_PLAN).setDomain("domain").setProject("project").setName("name").setVersion("version").build()).build()));
}
Also used : PartialLaunchPlanIdentifier(org.flyte.api.v1.PartialLaunchPlanIdentifier) WorkflowNode(org.flyte.api.v1.WorkflowNode) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with PartialLaunchPlanIdentifier

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

the class IdentifierRewriteTest method shouldRewriteWorkflowNodeForLaunchPlanRef.

@Test
void shouldRewriteWorkflowNodeForLaunchPlanRef() {
    PartialLaunchPlanIdentifier identifier = PartialLaunchPlanIdentifier.builder().name("name").build();
    PartialLaunchPlanIdentifier rewrittenIdentifier = PartialLaunchPlanIdentifier.builder().name("name").domain("rewritten-domain").version("rewritten-version").project("rewritten-project").build();
    WorkflowNode workflowNode = WorkflowNode.builder().reference(WorkflowNode.Reference.ofLaunchPlanRef(identifier)).build();
    assertThat(rewriter.visitor().visitWorkflowNode(workflowNode), equalTo(WorkflowNode.builder().reference(WorkflowNode.Reference.ofLaunchPlanRef(rewrittenIdentifier)).build()));
}
Also used : PartialLaunchPlanIdentifier(org.flyte.api.v1.PartialLaunchPlanIdentifier) WorkflowNode(org.flyte.api.v1.WorkflowNode) Test(org.junit.jupiter.api.Test)

Example 3 with PartialLaunchPlanIdentifier

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

the class IdentifierRewriteTest method shouldRewriteLaunchPlanIdentifierWithLatestIdAndDomainForRewriter.

@Test
void shouldRewriteLaunchPlanIdentifierWithLatestIdAndDomainForRewriter() {
    when(client.fetchLatestLaunchPlanId(NamedEntityIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-lp").build())).thenReturn(LaunchPlanIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-lp").version("latest-version").build());
    PartialLaunchPlanIdentifier rewrittenLaunchPlanId = rewriter.apply(PartialLaunchPlanIdentifier.builder().project("external-project").name("external-lp").build());
    assertThat(rewrittenLaunchPlanId, equalTo(PartialLaunchPlanIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-lp").version("latest-version").build()));
}
Also used : PartialLaunchPlanIdentifier(org.flyte.api.v1.PartialLaunchPlanIdentifier) Test(org.junit.jupiter.api.Test)

Example 4 with PartialLaunchPlanIdentifier

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

the class SdkRemoteLaunchPlan method apply.

@Override
public SdkNode apply(SdkWorkflowBuilder builder, String nodeId, List<String> upstreamNodeIds, @Nullable SdkNodeMetadata metadata, Map<String, SdkBindingData> inputs) {
    PartialLaunchPlanIdentifier workflowId = PartialLaunchPlanIdentifier.builder().name(name()).project(project()).domain(domain()).version(version()).build();
    List<CompilerError> errors = Compiler.validateApply(nodeId, inputs, inputs().getVariableMap());
    if (!errors.isEmpty()) {
        throw new CompilerException(errors);
    }
    Map<String, SdkBindingData> outputs = outputs().getVariableMap().entrySet().stream().collect(toUnmodifiableMap(Map.Entry::getKey, entry -> SdkBindingData.ofOutputReference(nodeId, entry.getKey(), entry.getValue().literalType())));
    return new SdkWorkflowNode(builder, nodeId, upstreamNodeIds, metadata, WorkflowNode.builder().reference(WorkflowNode.Reference.ofLaunchPlanRef(workflowId)).build(), inputs, outputs);
}
Also used : List(java.util.List) MoreCollectors.toUnmodifiableMap(org.flyte.flytekit.MoreCollectors.toUnmodifiableMap) Map(java.util.Map) AutoValue(com.google.auto.value.AutoValue) WorkflowNode(org.flyte.api.v1.WorkflowNode) PartialLaunchPlanIdentifier(org.flyte.api.v1.PartialLaunchPlanIdentifier) Nullable(javax.annotation.Nullable) PartialLaunchPlanIdentifier(org.flyte.api.v1.PartialLaunchPlanIdentifier) MoreCollectors.toUnmodifiableMap(org.flyte.flytekit.MoreCollectors.toUnmodifiableMap) Map(java.util.Map)

Aggregations

PartialLaunchPlanIdentifier (org.flyte.api.v1.PartialLaunchPlanIdentifier)4 WorkflowNode (org.flyte.api.v1.WorkflowNode)3 Test (org.junit.jupiter.api.Test)3 AutoValue (com.google.auto.value.AutoValue)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 MoreCollectors.toUnmodifiableMap (org.flyte.flytekit.MoreCollectors.toUnmodifiableMap)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1