Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Handle conditional in dynamic #301

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions jflyte/src/main/java/org/flyte/jflyte/ExecuteDynamicWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand All @@ -41,6 +42,7 @@
import org.flyte.api.v1.DynamicJobSpec;
import org.flyte.api.v1.DynamicWorkflowTask;
import org.flyte.api.v1.DynamicWorkflowTaskRegistrar;
import org.flyte.api.v1.IfBlock;
import org.flyte.api.v1.Literal;
import org.flyte.api.v1.NamedEntityIdentifier;
import org.flyte.api.v1.Node;
Expand Down Expand Up @@ -280,6 +282,28 @@ private static List<Node> collectAllUsedTaskTemplates(
flyteAdminClient,
cache);

// collect task templates used by conditionals
spec.nodes().stream()
.filter(node -> node.branchNode() != null)
.forEach(
node -> {
List<Node> nodes = new ArrayList<>();
nodes.add(node.branchNode().ifElse().case_().thenNode());
nodes.add(node.branchNode().ifElse().elseNode());
nodes.addAll(
node.branchNode().ifElse().other().stream()
.map(IfBlock::thenNode)
.collect(toList()));

collectTaskTemplates(
nodes,
nodesRewriter,
allUsedTaskTemplates,
allTaskTemplates,
flyteAdminClient,
cache);
});

// collect task templates used by subworkflows
allUsedSubWorkflows
.values()
Expand Down
Loading