use of org.flyte.api.v1.Node.START_NODE_ID in project flytekit-java by flyteorg.
the class ExecutionNodeCompiler method compile.
static ExecutionNode compile(Node node, Map<String, RunnableTask> runnableTasks, Map<String, DynamicWorkflowTask> dynamicWorkflowTasks) {
List<String> upstreamNodeIds = new ArrayList<>();
node.inputs().stream().map(Binding::binding).flatMap(ExecutionNodeCompiler::unpackBindingData).filter(x -> x.kind() == BindingData.Kind.PROMISE).map(x -> x.promise().nodeId()).forEach(upstreamNodeIds::add);
upstreamNodeIds.addAll(node.upstreamNodeIds());
if (upstreamNodeIds.isEmpty()) {
upstreamNodeIds.add(START_NODE_ID);
}
if (node.branchNode() != null) {
throw new IllegalArgumentException("BranchNode isn't yet supported for local execution");
}
if (node.workflowNode() != null) {
throw new IllegalArgumentException("WorkflowNode isn't yet supported for local execution");
}
String taskName = node.taskNode().referenceId().name();
DynamicWorkflowTask dynamicWorkflowTask = dynamicWorkflowTasks.get(taskName);
RunnableTask runnableTask = runnableTasks.get(taskName);
if (dynamicWorkflowTask != null) {
throw new IllegalArgumentException("DynamicWorkflowTask isn't yet supported for local execution");
}
Objects.requireNonNull(runnableTask, () -> String.format("Couldn't find task [%s]", taskName));
int attempts = runnableTask.getRetries().retries() + 1;
return ExecutionNode.builder().nodeId(node.id()).bindings(node.inputs()).runnableTask(runnableTask).upstreamNodeIds(upstreamNodeIds).attempts(attempts).build();
}
use of org.flyte.api.v1.Node.START_NODE_ID in project flytekit-java by flyteorg.
the class ExecutionNodeCompilerTest method testCompile_unknownTask.
@Test
void testCompile_unknownTask() {
Node node = createNode("node-1", ImmutableList.of(START_NODE_ID));
RuntimeException exception = assertThrows(RuntimeException.class, () -> ExecutionNodeCompiler.compile(node, emptyMap(), emptyMap()));
assertEquals("Couldn't find task [unknownTask]", exception.getMessage());
}
Aggregations