use of org.flyte.api.v1.WorkflowTemplate in project flytekit-java by flyteorg.
the class LocalEngineTest method testStructWorkflow.
@Test
public void testStructWorkflow() {
String workflowName = new StructWorkflow().getName();
Map<String, WorkflowTemplate> workflows = loadWorkflows();
Map<String, RunnableTask> tasks = loadTasks();
WorkflowTemplate workflow = workflows.get(workflowName);
Literal inputStructLiteral = Literal.ofScalar(Scalar.ofGeneric(Struct.of(ImmutableMap.of("someKey1", Struct.Value.ofStringValue("some_value_1"), "someKey2", Struct.Value.ofBoolValue(true)))));
Map<String, Literal> inputs = ImmutableMap.of("someString", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofStringValue("some_string_value"))), "someStruct", inputStructLiteral);
Map<String, Literal> outputs = LocalEngine.compileAndExecute(workflow, tasks, emptyMap(), inputs);
Literal expectedOutput = Literal.ofScalar(Scalar.ofGeneric(Struct.of(ImmutableMap.of("someKey1", Struct.Value.ofStringValue("some_value_1-output"), "someKey2", Struct.Value.ofBoolValue(true)))));
assertEquals(expectedOutput, outputs.get("outputStructData"));
}
use of org.flyte.api.v1.WorkflowTemplate in project flytekit-java by flyteorg.
the class SdkTestingExecutor method execute.
public Result execute() {
TestingSdkWorkflowBuilder builder = new TestingSdkWorkflowBuilder(fixedInputMap(), fixedInputTypeMap());
workflow().expand(builder);
WorkflowTemplate workflowTemplate = builder.toIdlTemplate();
for (Node node : workflowTemplate.nodes()) {
TaskNode taskNode = node.taskNode();
if (taskNode != null) {
String taskName = taskNode.referenceId().name();
checkArgument(fixedTaskMap().containsKey(taskName), "Can't execute remote task [%s], " + "use SdkTestingExecutor#withTaskOutput or SdkTestingExecutor#withTask", taskName);
}
}
Map<String, Literal> outputLiteralMap = LocalEngine.compileAndExecute(workflowTemplate, unmodifiableMap(fixedTaskMap()), emptyMap(), fixedInputMap());
Map<String, LiteralType> outputLiteralTypeMap = workflowTemplate.interface_().outputs().entrySet().stream().collect(toMap(Map.Entry::getKey, x -> x.getValue().literalType()));
return Result.create(outputLiteralMap, outputLiteralTypeMap);
}
use of org.flyte.api.v1.WorkflowTemplate in project flytekit-java by flyteorg.
the class SdkWorkflowWithSdkRemoteLaunchPlanTest method applyShouldReturnASdkWorkflowNode.
@Test
void applyShouldReturnASdkWorkflowNode() {
SdkWorkflowBuilder builder = new SdkWorkflowBuilder();
new WorkflowExample().expand(builder);
Node expectedNode = Node.builder().id("some-node-id").workflowNode(WorkflowNode.builder().reference(WorkflowNode.Reference.ofLaunchPlanRef(PartialLaunchPlanIdentifier.builder().domain("dev").project("project-a").name("SomeLaunchPlan").version("version").build())).build()).upstreamNodeIds(Collections.emptyList()).inputs(Arrays.asList(Binding.builder().var_("a").binding(BindingData.ofOutputReference(OutputReference.builder().nodeId("start-node").var("a").build())).build(), Binding.builder().var_("b").binding(BindingData.ofOutputReference(OutputReference.builder().nodeId("start-node").var("b").build())).build())).build();
WorkflowTemplate expected = WorkflowTemplate.builder().metadata(WorkflowMetadata.builder().build()).interface_(expectedInterface()).outputs(expectedOutputs()).nodes(singletonList(expectedNode)).build();
assertEquals(expected, builder.toIdlTemplate());
}
use of org.flyte.api.v1.WorkflowTemplate in project java-dataproc by googleapis.
the class ITSystemTest method getWorkflowTemplateTest.
@Test
public void getWorkflowTemplateTest() {
WorkflowTemplate response = workflowClient.getWorkflowTemplate(WORKFLOW_TEMPLATE_NAME);
assertEquals(ID, response.getId());
assertEquals(WORKFLOW_TEMPLATE_NAME.toString(), response.getName());
assertEquals(VERSION, response.getVersion());
}
use of org.flyte.api.v1.WorkflowTemplate in project flytekit-java by flyteorg.
the class FlyteAdminClientTest method shouldPropagateCreateWorkflowToStub.
@Test
public void shouldPropagateCreateWorkflowToStub() {
String nodeId = "node";
WorkflowIdentifier identifier = WorkflowIdentifier.builder().domain(DOMAIN).project(PROJECT).name(WF_NAME).version(WF_VERSION).build();
TaskNode taskNode = TaskNode.builder().referenceId(PartialTaskIdentifier.builder().domain(DOMAIN).project(PROJECT).name(TASK_NAME).version(TASK_VERSION).build()).build();
Node node = Node.builder().id(nodeId).taskNode(taskNode).inputs(ImmutableList.of(Binding.builder().var_(VAR_NAME).binding(BindingData.ofScalar(Scalar.ofPrimitive(Primitive.ofStringValue(SCALAR)))).build())).upstreamNodeIds(emptyList()).build();
TypedInterface interface_ = TypedInterface.builder().inputs(ImmutableMap.of()).outputs(ImmutableMap.of()).build();
WorkflowTemplate template = WorkflowTemplate.builder().nodes(ImmutableList.of(node)).metadata(WorkflowMetadata.builder().build()).interface_(interface_).outputs(ImmutableList.of()).build();
client.createWorkflow(identifier, template, ImmutableMap.of());
assertThat(stubService.createWorkflowRequest, equalTo(WorkflowOuterClass.WorkflowCreateRequest.newBuilder().setId(newIdentifier(ResourceType.WORKFLOW, WF_NAME, WF_VERSION)).setSpec(newWorkflowSpec(nodeId)).build()));
}
Aggregations