Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-10418

Support type hint annotations on CombineFn add_input() and extract_output()

Details

    • Improvement
    • Status: Triage Needed
    • P3
    • Resolution: Unresolved
    • None
    • None
    • sdk-py-core

    Description

      Similar to the tweaks for supporting native type hints on the PTransform.expand() method (https://issues.apache.org/jira/browse/BEAM-10258), it would be beneficial if the CombineFn class also received similar treatment, offering a way to provide type hints through the native Python hinting interface.

      Adding hints to the CombineFn's add_input() and extract_output() methods should be sufficient for providing the equivalent behavior of annotating the class with beam typehint decorators, e.g.,

      @beam.typehints.with_input_types(int)
      @beam.typehints.with_output_types(bool)
      class MyCombineFn(CombineFn):
        ...
      

      vs

      class MyCombineFn(CombineFn):
        def add_input(self, accumulator: float, element: int):
          ...
      
        def extract_output(self, accumulator: float) -> bool
          ...
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            metzen Matt McDonald
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: