use of org.flyte.api.v1.PartialTaskIdentifier in project flytekit-java by flyteorg.
the class IdentifierRewriteTest method shouldRewriteBranchNodes.
@Test
void shouldRewriteBranchNodes() {
ComparisonExpression comparison = ComparisonExpression.builder().operator(ComparisonExpression.Operator.EQ).leftValue(Operand.ofVar("a")).rightValue(Operand.ofVar("b")).build();
BooleanExpression condition = BooleanExpression.ofComparison(comparison);
PartialTaskIdentifier partialReference = PartialTaskIdentifier.builder().name("task-name").build();
PartialTaskIdentifier rewrittenReference = PartialTaskIdentifier.builder().name("task-name").domain("rewritten-domain").version("rewritten-version").project("rewritten-project").build();
TaskNode partialTaskNode = TaskNode.builder().referenceId(partialReference).build();
TaskNode rewrittenTaskNode = TaskNode.builder().referenceId(rewrittenReference).build();
Node partialNode = Node.builder().id("node-1").inputs(ImmutableList.of()).upstreamNodeIds(ImmutableList.of()).taskNode(partialTaskNode).build();
Node rewrittenNode = Node.builder().id("node-1").inputs(ImmutableList.of()).upstreamNodeIds(ImmutableList.of()).taskNode(rewrittenTaskNode).build();
IfBlock partialIfBlock = IfBlock.builder().condition(condition).thenNode(partialNode).build();
IfBlock rewrittenIfBlock = IfBlock.builder().condition(condition).thenNode(rewrittenNode).build();
BranchNode partialBranchNode = BranchNode.builder().ifElse(IfElseBlock.builder().case_(partialIfBlock).other(ImmutableList.of(partialIfBlock)).elseNode(partialNode).build()).build();
BranchNode rewrittenBranchNode = BranchNode.builder().ifElse(IfElseBlock.builder().case_(rewrittenIfBlock).other(ImmutableList.of(rewrittenIfBlock)).elseNode(rewrittenNode).build()).build();
assertThat(rewriter.visitor().visitBranchNode(partialBranchNode), equalTo(rewrittenBranchNode));
}
use of org.flyte.api.v1.PartialTaskIdentifier in project flytekit-java by flyteorg.
the class IdentifierRewriteTest method shouldRewriteTaskIdentifierWithValuesFromRewriterWhenOnlyNameIsSet.
@Test
void shouldRewriteTaskIdentifierWithValuesFromRewriterWhenOnlyNameIsSet() {
PartialTaskIdentifier rewrittenTaskId = rewriter.apply(PartialTaskIdentifier.builder().name("internal-task").build());
assertThat(rewrittenTaskId, equalTo(PartialTaskIdentifier.builder().project("rewritten-project").domain("rewritten-domain").name("internal-task").version("rewritten-version").build()));
}
use of org.flyte.api.v1.PartialTaskIdentifier in project flytekit-java by flyteorg.
the class SdkRemoteTask method apply.
@Override
public SdkNode apply(SdkWorkflowBuilder builder, String nodeId, List<String> upstreamNodeIds, @Nullable SdkNodeMetadata metadata, Map<String, SdkBindingData> inputs) {
PartialTaskIdentifier taskId = PartialTaskIdentifier.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);
}
return new SdkTaskNode(builder, nodeId, taskId, upstreamNodeIds, metadata, inputs, outputs().getVariableMap());
}
use of org.flyte.api.v1.PartialTaskIdentifier in project flytekit-java by flyteorg.
the class IdentifierRewriteTest method shouldRewriteTaskAllowingPingingVersionForTasksSameProject.
@Test
void shouldRewriteTaskAllowingPingingVersionForTasksSameProject() {
PartialTaskIdentifier rewrittenTaskId = rewriter.apply(PartialTaskIdentifier.builder().name("internal-task").version("pinned-version").build());
assertThat(rewrittenTaskId, equalTo(PartialTaskIdentifier.builder().project("rewritten-project").domain("rewritten-domain").name("internal-task").version("pinned-version").build()));
verifyNoInteractions(client);
}
use of org.flyte.api.v1.PartialTaskIdentifier in project flytekit-java by flyteorg.
the class IdentifierRewriteTest method shouldRewriteTaskIdentifierWithLatestIdAndDomainForRewriter.
@Test
void shouldRewriteTaskIdentifierWithLatestIdAndDomainForRewriter() {
when(client.fetchLatestTaskId(NamedEntityIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-task").build())).thenReturn(TaskIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-task").version("latest-version").build());
PartialTaskIdentifier rewrittenTaskId = rewriter.apply(PartialTaskIdentifier.builder().project("external-project").name("external-task").build());
assertThat(rewrittenTaskId, equalTo(PartialTaskIdentifier.builder().project("external-project").domain("rewritten-domain").name("external-task").version("latest-version").build()));
}
Aggregations