Skip to content

Commit

Permalink
Configure FAIL_IMMEDIATELY default in the builder
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgomezfrr committed Aug 10, 2023
1 parent c236c16 commit 514350d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.flyte.api.v1;

import com.google.auto.value.AutoValue;
import org.flyte.api.v1.OnFailurePolicy.Kind;

/** Metadata for the entire workflow. */
@AutoValue
Expand All @@ -25,7 +26,8 @@ public abstract class WorkflowMetadata {
public abstract OnFailurePolicy onFailure();

public static Builder builder() {
return new AutoValue_WorkflowMetadata.Builder();
return new AutoValue_WorkflowMetadata.Builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build());
}

@AutoValue.Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public abstract class SdkWorkflowMetadata {
public abstract OnFailurePolicy onFailure();

public static Builder builder() {
return new AutoValue_SdkWorkflowMetadata.Builder();
return new AutoValue_SdkWorkflowMetadata.Builder()
.onFailure(OnFailurePolicy.builder().kind(OnFailurePolicy.Kind.FAIL_IMMEDIATELY).build());
}

@AutoValue.Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import org.flyte.api.v1.Node;
import org.flyte.api.v1.NodeError;
import org.flyte.api.v1.NodeMetadata;
import org.flyte.api.v1.OnFailurePolicy;
import org.flyte.api.v1.OnFailurePolicy.Kind;
import org.flyte.api.v1.Operand;
import org.flyte.api.v1.OutputReference;
import org.flyte.api.v1.PartialTaskIdentifier;
Expand Down Expand Up @@ -131,10 +129,7 @@ void testTimes4WorkflowIdl() {

WorkflowTemplate expected =
WorkflowTemplate.builder()
.metadata(
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build())
.metadata(WorkflowMetadata.builder().build())
.interface_(expectedInterface())
.outputs(expectedOutputs("foo-n1"))
.nodes(List.of(node0, node1))
Expand Down Expand Up @@ -222,10 +217,7 @@ void testConditionalWorkflowIdl() {

WorkflowTemplate expected =
WorkflowTemplate.builder()
.metadata(
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build())
.metadata(WorkflowMetadata.builder().build())
.interface_(expectedInterface())
.outputs(expectedOutputs("square"))
.nodes(singletonList(expectedNode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import org.flyte.api.v1.BindingData;
import org.flyte.api.v1.Node;
import org.flyte.api.v1.NodeMetadata;
import org.flyte.api.v1.OnFailurePolicy;
import org.flyte.api.v1.OnFailurePolicy.Kind;
import org.flyte.api.v1.OutputReference;
import org.flyte.api.v1.PartialLaunchPlanIdentifier;
import org.flyte.api.v1.TypedInterface;
Expand Down Expand Up @@ -82,10 +80,7 @@ void applyShouldReturnASdkWorkflowNode() {
.build();
WorkflowTemplate expected =
WorkflowTemplate.builder()
.metadata(
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build())
.metadata(WorkflowMetadata.builder().build())
.interface_(expectedInterface())
.outputs(expectedOutputs())
.nodes(singletonList(expectedNode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
import org.flyte.api.v1.LiteralType;
import org.flyte.api.v1.NamedEntityIdentifier;
import org.flyte.api.v1.Node;
import org.flyte.api.v1.OnFailurePolicy;
import org.flyte.api.v1.OnFailurePolicy.Kind;
import org.flyte.api.v1.Parameter;
import org.flyte.api.v1.PartialTaskIdentifier;
import org.flyte.api.v1.PartialWorkflowIdentifier;
Expand Down Expand Up @@ -220,10 +218,7 @@ public void shouldPropagateCreateWorkflowToStub() {
WorkflowTemplate template =
WorkflowTemplate.builder()
.nodes(ImmutableList.of(node))
.metadata(
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build())
.metadata(WorkflowMetadata.builder().build())
.interface_(interface_)
.outputs(ImmutableList.of())
.build();
Expand Down
12 changes: 2 additions & 10 deletions jflyte/src/test/java/org/flyte/jflyte/ProjectClosureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.flyte.api.v1.LaunchPlanIdentifier;
import org.flyte.api.v1.Literal;
import org.flyte.api.v1.Node;
import org.flyte.api.v1.OnFailurePolicy;
import org.flyte.api.v1.OnFailurePolicy.Kind;
import org.flyte.api.v1.Operand;
import org.flyte.api.v1.PartialWorkflowIdentifier;
import org.flyte.api.v1.Primitive;
Expand Down Expand Up @@ -99,10 +97,7 @@ public void testCollectSubWorkflows() {
TypedInterface emptyInterface =
TypedInterface.builder().inputs(ImmutableMap.of()).outputs(ImmutableMap.of()).build();

WorkflowMetadata emptyMetadata =
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build();
WorkflowMetadata emptyMetadata = WorkflowMetadata.builder().build();

PartialWorkflowIdentifier rewrittenSubWorkflowRef =
PartialWorkflowIdentifier.builder()
Expand Down Expand Up @@ -276,10 +271,7 @@ public void testCheckCycles() {
TypedInterface emptyInterface =
TypedInterface.builder().inputs(ImmutableMap.of()).outputs(ImmutableMap.of()).build();

WorkflowMetadata emptyMetadata =
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build();
WorkflowMetadata emptyMetadata = WorkflowMetadata.builder().build();

PartialWorkflowIdentifier rewrittenWorkflowRef =
PartialWorkflowIdentifier.builder()
Expand Down
7 changes: 1 addition & 6 deletions jflyte/src/test/java/org/flyte/jflyte/ProtoUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@
import org.flyte.api.v1.Node;
import org.flyte.api.v1.NodeError;
import org.flyte.api.v1.NodeMetadata;
import org.flyte.api.v1.OnFailurePolicy;
import org.flyte.api.v1.OnFailurePolicy.Kind;
import org.flyte.api.v1.Operand;
import org.flyte.api.v1.OutputReference;
import org.flyte.api.v1.PartialLaunchPlanIdentifier;
Expand Down Expand Up @@ -592,10 +590,7 @@ void shouldSerializeWorkflowTemplate() {
.build())
.build();

WorkflowMetadata metadata =
WorkflowMetadata.builder()
.onFailure(OnFailurePolicy.builder().kind(Kind.FAIL_IMMEDIATELY).build())
.build();
WorkflowMetadata metadata = WorkflowMetadata.builder().build();
TypedInterface interface_ =
TypedInterface.builder().inputs(emptyMap()).outputs(emptyMap()).build();
WorkflowTemplate template =
Expand Down

0 comments on commit 514350d

Please sign in to comment.