You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/03/10 02:31:56 UTC

[GitHub] [beam] chamikaramj commented on a change in pull request #13729: [BEAM-11592] Adding cross-language test using third-party Python dependencies

chamikaramj commented on a change in pull request #13729:
URL: https://github.com/apache/beam/pull/13729#discussion_r590942362



##########
File path: sdks/python/apache_beam/runners/portability/expansion_service_test.py
##########
@@ -298,6 +324,10 @@ def main(unused_argv):
           PipelineOptions(
               ["--experiments", "beam_fn_api", "--sdk_location", "container"])),
       server)
+  beam_artifact_api_pb2_grpc.add_ArtifactRetrievalServiceServicer_to_server(

Review comment:
       Is there a way to tag an artifact just for a given transforms instead of all transforms registered in the expansion service ? (probably future work).

##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/testing/UsesPythonExpansionService.java
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.sdk.testing;
+
+import org.apache.beam.sdk.annotations.Internal;
+
+/**
+ * Category tag for tests which use the expansion service in Python. Tests tagged with {@link
+ * UsesPythonExpansionService} should be run for runners which support cross-language transforms.

Review comment:
       Is that different from runners that can run tests tagged with UsesCrossLanguageTransforms ?

##########
File path: sdks/python/apache_beam/runners/portability/expansion_service_test.py
##########
@@ -226,6 +230,27 @@ def from_runner_api_parameter(
     return PartitionTransform()
 
 
+class ExtractHtmlTitleDoFn(beam.DoFn):
+  def process(self, element):
+    from bs4 import BeautifulSoup
+    soup = BeautifulSoup(element, 'html.parser')
+    return [soup.title.string]
+
+
+@ptransform.PTransform.register_urn(TEST_PYTHON_BS4_URN, None)
+class ExtractHtmlTitleTransform(ptransform.PTransform):
+  def expand(self, pcoll):
+    return pcoll | beam.ParDo(ExtractHtmlTitleDoFn()).with_output_types(unicode)
+
+  def to_runner_api_parameter(self, unused_context):

Review comment:
       Bit unrelated but why did we decide to require to_runner_api_parameter/from_runner_api_parameter
   instead of builders for using Python from Java ? Or is this just one way of defining Python x-lang transforms ?




----------------------------------------------------------------
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:
users@infra.apache.org