You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/08 05:01:33 UTC

[GitHub] [flink] HuangXingBo opened a new pull request, #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

HuangXingBo opened a new pull request, #20488:
URL: https://github.com/apache/flink/pull/20488

   ## What is the purpose of the change
   
   *This pull request will support SideOutput in Thread Mode*
   
   
   ## Brief change log
   
     - *Support SideOutput in Thread Mode*
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *`EmbeddedDataStreamStreamTests` and `EmbeddedDataStreamBatchTests` in `test_data_stream.py`*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] HuangXingBo closed pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

Posted by GitBox <gi...@apache.org>.
HuangXingBo closed pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode
URL: https://github.com/apache/flink/pull/20488


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] HuangXingBo commented on a diff in pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

Posted by GitBox <gi...@apache.org>.
HuangXingBo commented on code in PR #20488:
URL: https://github.com/apache/flink/pull/20488#discussion_r939904633


##########
flink-python/pyflink/fn_execution/datastream/embedded/side_output_context.py:
##########
@@ -0,0 +1,42 @@
+################################################################################
+#  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.
+################################################################################
+from typing import Dict
+
+from pyflink.fn_execution.embedded.converters import from_type_info_proto, DataConverter
+
+
+class SideOutputContext(object):
+    def __init__(self, context):
+        self._context = context
+        self._side_output_converters = (
+            {tag_id: from_type_info_proto(_parse_type_info_proto(payload))
+             for tag_id, payload in
+             context.getAllSideOutputTypeInfoPayloads().items()})  # type: Dict[str, DataConverter]
+
+    def collect(self, tag_id: str, record):
+        self._context.collectSideOutputById(
+            tag_id,
+            self._side_output_converters[tag_id].to_external(record))

Review Comment:
   I think raise an Exception to is a better choice so that users can know they have some typo error.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #20488:
URL: https://github.com/apache/flink/pull/20488#issuecomment-1207671881

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "800d4586334e80172a19f94ada0cc2693239f9cc",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "800d4586334e80172a19f94ada0cc2693239f9cc",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 800d4586334e80172a19f94ada0cc2693239f9cc UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] HuangXingBo commented on pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

Posted by GitBox <gi...@apache.org>.
HuangXingBo commented on PR #20488:
URL: https://github.com/apache/flink/pull/20488#issuecomment-1208088709

   tests passed in my private azure https://dev.azure.com/hxbks2ks/FLINK-TEST/_build/results?buildId=1969&view=logs&j=fba17979-6d2e-591d-72f1-97cf42797c11&t=727942b6-6137-54f7-1ef9-e66e706ea068


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] Vancior commented on a diff in pull request #20488: [FLINK-28788][python] Support SideOutput in Thread Mode

Posted by GitBox <gi...@apache.org>.
Vancior commented on code in PR #20488:
URL: https://github.com/apache/flink/pull/20488#discussion_r939883325


##########
flink-python/pyflink/fn_execution/datastream/embedded/side_output_context.py:
##########
@@ -0,0 +1,42 @@
+################################################################################
+#  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.
+################################################################################
+from typing import Dict
+
+from pyflink.fn_execution.embedded.converters import from_type_info_proto, DataConverter
+
+
+class SideOutputContext(object):
+    def __init__(self, context):
+        self._context = context
+        self._side_output_converters = (
+            {tag_id: from_type_info_proto(_parse_type_info_proto(payload))
+             for tag_id, payload in
+             context.getAllSideOutputTypeInfoPayloads().items()})  # type: Dict[str, DataConverter]
+
+    def collect(self, tag_id: str, record):
+        self._context.collectSideOutputById(
+            tag_id,
+            self._side_output_converters[tag_id].to_external(record))

Review Comment:
   Do we need change default behavior of using a undefined output tag to ignore rather than throw a KeyError?



##########
flink-python/src/main/java/org/apache/flink/streaming/api/operators/python/embedded/AbstractEmbeddedDataStreamPythonFunctionOperator.java:
##########
@@ -104,4 +134,45 @@ public Map<String, String> getJobParameters() {
         }
         return jobParameters;
     }
+
+    private class SideOutputContext {
+
+        private Map<String, byte[]> sideOutputTypeInfoPayloads = new HashMap<>();
+
+        private Map<String, PythonTypeUtils.DataConverter<Object, Object>>
+                sideOutputDataConverters = new HashMap<>();
+
+        @SuppressWarnings("unchecked")
+        public void open() {
+            for (Map.Entry<String, OutputTag<?>> entry : sideOutputTags.entrySet()) {
+                sideOutputTypeInfoPayloads.put(
+                        entry.getKey(), getSideOutputTypeInfoPayload(entry.getValue()));
+
+                sideOutputDataConverters.put(
+                        entry.getKey(),
+                        PythonTypeUtils.TypeInfoToDataConverter.typeInfoDataConverter(
+                                (TypeInformation) entry.getValue().getTypeInfo()));
+            }
+        }
+
+        @SuppressWarnings("unchecked")
+        public void collectSideOutputById(String id, Object record) {
+            OutputTag<?> outputTag = sideOutputTags.get(id);

Review Comment:
   If reached (when KeyError mentioned above is solved), undefined output tag records will flow into the main stream.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org