[
https://issues.apache.org/jira/browse/BEAM-2590?focusedWorklogId=222329&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-222329
]
ASF GitHub Bot logged work on BEAM-2590:
----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Apr/19 14:15
Start Date: 03/Apr/19 14:15
Worklog Time Spent: 10m
Work Description: iemejia commented on pull request #8115: [BEAM-2590]
Implement basic Spark portable runner
URL: https://github.com/apache/beam/pull/8115#discussion_r271635285
##########
File path:
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.spark;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import org.apache.beam.model.pipeline.v1.RunnerApi;
+import org.apache.beam.model.pipeline.v1.RunnerApi.Pipeline;
+import org.apache.beam.runners.core.construction.graph.GreedyPipelineFuser;
+import org.apache.beam.runners.core.construction.graph.PipelineTrimmer;
+import
org.apache.beam.runners.fnexecution.jobsubmission.PortablePipelineRunner;
+import org.apache.beam.runners.fnexecution.provisioning.JobInfo;
+import org.apache.beam.runners.spark.aggregators.AggregatorsAccumulator;
+import
org.apache.beam.runners.spark.translation.SparkBatchPortablePipelineTranslator;
+import org.apache.beam.runners.spark.translation.SparkContextFactory;
+import org.apache.beam.runners.spark.translation.SparkTranslationContext;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Runs a portable pipeline on Apache Spark. */
+public class SparkPipelineRunner implements PortablePipelineRunner {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(SparkPipelineRunner.class);
+
+ private final SparkPipelineOptions pipelineOptions;
+
+ public SparkPipelineRunner(SparkPipelineOptions pipelineOptions) {
+ this.pipelineOptions = pipelineOptions;
+ }
+
+ @Override
+ public SparkPipelineResult run(RunnerApi.Pipeline pipeline, JobInfo jobInfo)
{
+ SparkBatchPortablePipelineTranslator translator = new
SparkBatchPortablePipelineTranslator();
+
+ // Don't let the fuser fuse any subcomponents of native transforms.
+ Pipeline trimmedPipeline = PipelineTrimmer.trim(pipeline,
translator.knownUrns());
+ Pipeline fusedPipeline =
GreedyPipelineFuser.fuse(trimmedPipeline).toPipeline();
+
+ final JavaSparkContext jsc =
SparkContextFactory.getSparkContext(pipelineOptions);
+ LOG.info(String.format("Running job %s on Spark master %s",
jobInfo.jobId(), jsc.master()));
+ AggregatorsAccumulator.init(pipelineOptions, jsc);
+ final SparkTranslationContext context =
+ new SparkTranslationContext(jsc, pipelineOptions, jobInfo);
+ final ExecutorService executorService =
Executors.newSingleThreadExecutor();
+ final Future<?> submissionFuture =
+ executorService.submit(
+ () -> {
+ translator.translate(fusedPipeline, context);
+ LOG.info(
+ String.format(
+ "Job %s: Pipeline translated successfully. Computing
outputs",
+ jobInfo.jobId()));
+ context.computeOutputs();
+ LOG.info(String.format("Job %s finished.", jobInfo.jobId()));
+ });
+
+ SparkPipelineResult result = new
SparkPipelineResult.BatchMode(submissionFuture, jsc);
+ result.waitUntilFinish();
Review comment:
Can we avoid forcing `waitUntilFinish` upfront ? (maybe in future PR)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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: 222329)
Time Spent: 1h 50m (was: 1h 40m)
> SparkRunner shim for Job API
> ----------------------------
>
> Key: BEAM-2590
> URL: https://issues.apache.org/jira/browse/BEAM-2590
> Project: Beam
> Issue Type: Sub-task
> Components: runner-spark
> Reporter: Kenneth Knowles
> Assignee: Kyle Weaver
> Priority: Major
> Labels: portability, triaged
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> Whatever the result of https://s.apache.org/beam-job-api we will need a way
> for the JVM-based SparkRunner to receive and run pipelines authors in Python.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)