Search in sources :

Example 1 with SdkWorkflow

use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.

the class SdkTestingExecutorTest method testWithFixedInput_illegalType.

@Test
public void testWithFixedInput_illegalType() {
    SdkWorkflow workflow = new SdkWorkflow() {

        @Override
        public void expand(SdkWorkflowBuilder builder) {
            builder.output("string", builder.inputOfString("string"));
        }
    };
    IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).withFixedInput("string", 42).execute());
    assertThat(e.getMessage(), equalTo("Fixed input [string] (of type INTEGER) doesn't match expected type STRING"));
}
Also used : SdkWorkflowBuilder(org.flyte.flytekit.SdkWorkflowBuilder) SdkWorkflow(org.flyte.flytekit.SdkWorkflow) Test(org.junit.jupiter.api.Test)

Example 2 with SdkWorkflow

use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.

the class SdkTestingExecutorTest method testGetOutput_doesntExist.

@Test
public void testGetOutput_doesntExist() {
    SdkWorkflow workflow = new SdkWorkflow() {

        @Override
        public void expand(SdkWorkflowBuilder builder) {
            builder.output("integer", builder.inputOfInteger("integer"));
        }
    };
    SdkTestingExecutor.Result result = SdkTestingExecutor.of(workflow).withFixedInput("integer", 42).execute();
    IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> result.getStringOutput("string"));
    assertThat(e.getMessage(), equalTo("Output [string] doesn't exist in [integer]"));
}
Also used : SdkWorkflowBuilder(org.flyte.flytekit.SdkWorkflowBuilder) SdkWorkflow(org.flyte.flytekit.SdkWorkflow) Test(org.junit.jupiter.api.Test)

Example 3 with SdkWorkflow

use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.

the class SdkTestingExecutorTest method testPrimitiveTypes.

@Test
public void testPrimitiveTypes() {
    SdkWorkflow workflow = new SdkWorkflow() {

        @Override
        public void expand(SdkWorkflowBuilder builder) {
            builder.output("boolean", builder.inputOfBoolean("boolean"));
            builder.output("datetime", builder.inputOfDatetime("datetime"));
            builder.output("duration", builder.inputOfDuration("duration"));
            builder.output("float", builder.inputOfFloat("float"));
            builder.output("integer", builder.inputOfInteger("integer"));
            builder.output("string", builder.inputOfString("string"));
        }
    };
    SdkTestingExecutor.Result result = SdkTestingExecutor.of(workflow).withFixedInput("boolean", true).withFixedInput("datetime", Instant.ofEpochSecond(1337)).withFixedInput("duration", Duration.ofDays(1)).withFixedInput("float", 1337.0).withFixedInput("integer", 42).withFixedInput("string", "forty two").execute();
    assertThat(result.getBooleanOutput("boolean"), equalTo(true));
    assertThat(result.getDatetimeOutput("datetime"), equalTo(Instant.ofEpochSecond(1337)));
    assertThat(result.getDurationOutput("duration"), equalTo(Duration.ofDays(1)));
    assertThat(result.getFloatOutput("float"), equalTo(1337.0));
    assertThat(result.getIntegerOutput("integer"), equalTo(42L));
    assertThat(result.getStringOutput("string"), equalTo("forty two"));
}
Also used : SdkWorkflowBuilder(org.flyte.flytekit.SdkWorkflowBuilder) SdkWorkflow(org.flyte.flytekit.SdkWorkflow) Test(org.junit.jupiter.api.Test)

Example 4 with SdkWorkflow

use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.

the class SdkTestingExecutorTest method testWithTask_missingRemoteTask.

@Test
public void testWithTask_missingRemoteTask() {
    SdkWorkflow workflow = new SdkWorkflow() {

        @Override
        public void expand(SdkWorkflowBuilder builder) {
            builder.apply("sum", RemoteSumTask.create().withInput("a", 1L).withInput("b", 2L));
        }
    };
    IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).execute());
    assertThat(e.getMessage(), equalTo("Can't execute remote task [remote_sum_task], use SdkTestingExecutor#withTaskOutput or " + "SdkTestingExecutor#withTask"));
}
Also used : SdkWorkflowBuilder(org.flyte.flytekit.SdkWorkflowBuilder) SdkWorkflow(org.flyte.flytekit.SdkWorkflow) Test(org.junit.jupiter.api.Test)

Example 5 with SdkWorkflow

use of org.flyte.flytekit.SdkWorkflow in project flytekit-java by flyteorg.

the class SdkTestingExecutorTest method testWithTask_missingRemoteTaskOutput.

@Test
public void testWithTask_missingRemoteTaskOutput() {
    SdkWorkflow workflow = new SdkWorkflow() {

        @Override
        public void expand(SdkWorkflowBuilder builder) {
            builder.apply("sum", RemoteSumTask.create().withInput("a", 1L).withInput("b", 2L));
        }
    };
    IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> SdkTestingExecutor.of(workflow).withTaskOutput(RemoteSumTask.create(), RemoteSumInput.create(10L, 20L), RemoteSumOutput.create(30L)).execute());
    assertThat(e.getMessage(), equalTo("Can't find input RemoteSumInput{a=1, b=2} for remote task [remote_sum_task] across known " + "task inputs, use SdkTestingExecutor#withTaskOutput or SdkTestingExecutor#withTask"));
}
Also used : SdkWorkflowBuilder(org.flyte.flytekit.SdkWorkflowBuilder) SdkWorkflow(org.flyte.flytekit.SdkWorkflow) Test(org.junit.jupiter.api.Test)

Aggregations

SdkWorkflow (org.flyte.flytekit.SdkWorkflow)8 SdkWorkflowBuilder (org.flyte.flytekit.SdkWorkflowBuilder)8 Test (org.junit.jupiter.api.Test)8