[
https://issues.apache.org/jira/browse/BEAM-3913?focusedWorklogId=85062&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-85062
]
ASF GitHub Bot logged work on BEAM-3913:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Mar/18 22:41
Start Date: 27/Mar/18 22:41
Worklog Time Spent: 10m
Work Description: lukecwik closed pull request #4938: [BEAM-3913] Allow
Fusion to Continue with unknown PTransforms
URL: https://github.com/apache/beam/pull/4938
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/graph/GreedyPCollectionFusers.java
b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/graph/GreedyPCollectionFusers.java
index 050757c8f37..f55b60df905 100644
---
a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/graph/GreedyPCollectionFusers.java
+++
b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/graph/GreedyPCollectionFusers.java
@@ -27,17 +27,22 @@
import java.util.Optional;
import org.apache.beam.model.pipeline.v1.RunnerApi.Environment;
import org.apache.beam.model.pipeline.v1.RunnerApi.PCollection;
+import org.apache.beam.model.pipeline.v1.RunnerApi.PTransform;
import org.apache.beam.model.pipeline.v1.RunnerApi.ParDoPayload;
import org.apache.beam.model.pipeline.v1.RunnerApi.Pipeline;
import org.apache.beam.runners.core.construction.PTransformTranslation;
import
org.apache.beam.runners.core.construction.graph.PipelineNode.PCollectionNode;
import
org.apache.beam.runners.core.construction.graph.PipelineNode.PTransformNode;
import org.apache.beam.sdk.transforms.Flatten;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A Fuser that constructs a fused pipeline by fusing as many PCollections
into a stage as possible.
*/
class GreedyPCollectionFusers {
+ private static final Logger LOG =
LoggerFactory.getLogger(GreedyPCollectionFusers.class);
+
private static final Map<String, FusibilityChecker> URN_FUSIBILITY_CHECKERS =
ImmutableMap.<String, FusibilityChecker>builder()
.put(PTransformTranslation.PAR_DO_TRANSFORM_URN,
GreedyPCollectionFusers::canFuseParDo)
@@ -271,21 +276,34 @@ private static boolean noCompatibility(
return false;
}
+ // Things with unknown URNs either execute within their own stage or are
executed by the runner.
+ // In either case, assume the system is capable of executing the expressed
transform
private static boolean unknownTransformFusion(
PTransformNode transform,
@SuppressWarnings("unused") Environment environment,
@SuppressWarnings("unused") Collection<PCollectionNode>
stagePCollections,
@SuppressWarnings("unused") QueryablePipeline pipeline) {
- throw new IllegalArgumentException(
- String.format("Unknown URN %s",
transform.getTransform().getSpec().getUrn()));
+ LOG.debug(
+ "Unknown {} {} will not fuse into an existing {}",
+ PTransform.class.getSimpleName(),
+ transform.getTransform(),
+ ExecutableStage.class.getSimpleName(),
+ PTransform.class.getSimpleName());
+ return false;
}
+ // Things with unknown URNs either execute within their own stage or are
executed by the runner.
+ // In either case, assume the system is capable of executing the expressed
transform
private static boolean unknownTransformCompatibility(
PTransformNode transform,
@SuppressWarnings("unused") PTransformNode other,
@SuppressWarnings("unused") QueryablePipeline pipeline) {
- throw new IllegalArgumentException(
- String.format(
- "Unknown or unsupported URN %s",
transform.getTransform().getSpec().getUrn()));
+ LOG.debug(
+ "Unknown {} {} will not root a {} with other {}",
+ PTransform.class.getSimpleName(),
+ transform.getTransform(),
+ ExecutableStage.class.getSimpleName(),
+ PTransform.class.getSimpleName());
+ return false;
}
}
diff --git
a/runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/graph/GreedyPipelineFuserTest.java
b/runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/graph/GreedyPipelineFuserTest.java
index 6387bf0435b..fb9051f7de4 100644
---
a/runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/graph/GreedyPipelineFuserTest.java
+++
b/runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/graph/GreedyPipelineFuserTest.java
@@ -20,6 +20,7 @@
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.emptyIterable;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
@@ -139,6 +140,48 @@ public void singleEnvironmentBecomesASingleStage() {
.withTransforms("read", "parDo", "window")));
}
+ /*
+ * impulse -> .out -> mystery -> .out
+ * \
+ * -> enigma -> .out
+ * becomes all runner-executed
+ */
+ @Test
+ public void unknownTransformsNoEnvironmentBecomeRunnerExecuted() {
+ Components components =
+ partialComponents
+ .toBuilder()
+ .putTransforms(
+ "mystery",
+ PTransform.newBuilder()
+ .putInputs("input", "impulse.out")
+ .putOutputs("output", "mystery.out")
+
.setSpec(FunctionSpec.newBuilder().setUrn("beam:transform:mystery:v1.4"))
+ .build())
+ .putPcollections(
+ "mystery.out",
PCollection.newBuilder().setUniqueName("mystery.out").build())
+ .putTransforms(
+ "enigma",
+ PTransform.newBuilder()
+ .putInputs("input", "impulse.out")
+ .putOutputs("output", "enigma.out")
+
.setSpec(FunctionSpec.newBuilder().setUrn("beam:transform:enigma:v1"))
+ .build())
+ .putPcollections(
+ "enigma.out",
PCollection.newBuilder().setUniqueName("enigma.out").build())
+ .build();
+ FusedPipeline fused =
+
GreedyPipelineFuser.fuse(Pipeline.newBuilder().setComponents(components).build());
+
+ assertThat(
+ fused.getRunnerExecutedTransforms(),
+ containsInAnyOrder(
+ PipelineNode.pTransform("impulse",
components.getTransformsOrThrow("impulse")),
+ PipelineNode.pTransform("mystery",
components.getTransformsOrThrow("mystery")),
+ PipelineNode.pTransform("enigma",
components.getTransformsOrThrow("enigma"))));
+ assertThat(fused.getFusedStages(), emptyIterable());
+ }
+
/*
* impulse -> .out -> read -> .out -> groupByKey -> .out -> parDo -> .out
* becomes
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 85062)
Time Spent: 50m (was: 40m)
> Support custom runner primitives in Fusion
> ------------------------------------------
>
> Key: BEAM-3913
> URL: https://issues.apache.org/jira/browse/BEAM-3913
> Project: Beam
> Issue Type: Improvement
> Components: runner-core
> Reporter: Thomas Groh
> Assignee: Thomas Groh
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Effectively, register runner-provided transform URNs in the
> GreedyPCollectionFusers to understand runner-specific primitives, and don't
> ever fuse them.
>
> It's probably appropriate to continue to crash when encountering truly
> unknown URNs
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)