Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions runners/flink/job-server/flink_job_server.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ createCrossLanguageValidatesRunnerTask(
"--environmentCacheMillis=10000",
"--experiments=beam_fn_api",
"--parallelism=2",
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
],
goScriptOptions: [
"--runner flink",
Expand Down
1 change: 1 addition & 0 deletions runners/google-cloud-dataflow-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ createCrossLanguageValidatesRunnerTask(
"--tempRoot=${dataflowValidatesTempRoot}",
"--sdkContainerImage=${dockerJavaImageContainer}:${dockerTag}",
"--sdkHarnessContainerImageOverrides=.*python.*,${dockerPythonImageContainer}:${dockerTag}",
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
],
pytestOptions: [
"--capture=no",
Expand Down
1 change: 1 addition & 0 deletions runners/samza/job-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ createCrossLanguageValidatesRunnerTask(
"--jobEndpoint=localhost:${jobPort}",
"--environmentCacheMillis=10000",
"--experiments=beam_fn_api",
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
],
goScriptOptions: [
"--runner samza",
Expand Down
1 change: 1 addition & 0 deletions runners/spark/job-server/spark_job_server.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ createCrossLanguageValidatesRunnerTask(
"--jobEndpoint=localhost:${jobPort}",
"--environmentCacheMillis=10000",
"--experiments=beam_fn_api",
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
],
goScriptOptions: [
"--runner spark",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.beam.sdk.schemas.SchemaTranslation;
import org.apache.beam.sdk.schemas.logicaltypes.MicrosInstant;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.testing.TestPipeline;
import org.apache.beam.sdk.testing.UsesPythonExpansionService;
import org.apache.beam.sdk.testing.ValidatesRunner;
import org.apache.beam.sdk.transforms.Create;
Expand All @@ -43,43 +44,45 @@
import org.apache.beam.sdk.values.Row;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class PythonExternalTransformTest implements Serializable {
@Rule public transient TestPipeline testPipeline = TestPipeline.create();

@Test
@Category({ValidatesRunner.class, UsesPythonExpansionService.class})
public void trivialPythonTransform() {
Pipeline p = Pipeline.create();
PCollection<String> output =
p.apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z")))
testPipeline
.apply(Create.of(KV.of("A", "x"), KV.of("A", "y"), KV.of("B", "z")))
.apply(
PythonExternalTransform
.<PCollection<KV<String, String>>, PCollection<KV<String, Iterable<String>>>>
from("apache_beam.GroupByKey"))
.apply(Keys.create());
PAssert.that(output).containsInAnyOrder("A", "B");
// TODO: Run this on a multi-language supporting runner.
testPipeline.run();
}

@Test
@Category({ValidatesRunner.class, UsesPythonExpansionService.class})
public void pythonTransformWithDependencies() {
Pipeline p = Pipeline.create();
PCollection<String> output =
p.apply(Create.of("elephant", "mouse", "sheep"))
testPipeline
.apply(Create.of("elephant", "mouse", "sheep"))
.apply(
PythonExternalTransform.<PCollection<String>, PCollection<String>>from(
"apache_beam.Map")
.withArgs(PythonCallableSource.of("import inflection\ninflection.pluralize"))
.withExtraPackages(ImmutableList.of("inflection"))
.withOutputCoder(StringUtf8Coder.of()));
PAssert.that(output).containsInAnyOrder("elephants", "mice", "sheep");
// TODO: Run this on a multi-language supporting runner.
testPipeline.run();
}

@Test
Expand Down
1 change: 1 addition & 0 deletions sdks/python/test-suites/direct/xlang/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ createCrossLanguageValidatesRunnerTask(
"--jobEndpoint=localhost:${jobPort}",
"--environmentCacheMillis=10000",
"--experiments=beam_fn_api",
"--customBeamRequirement=${project.project(":sdks:python").projectDir}/build/apache-beam.tar.gz",
],
goScriptOptions: [
"--runner portable",
Expand Down
Loading