[ 
https://issues.apache.org/jira/browse/BEAM-8519?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yifan Mai updated BEAM-8519:
----------------------------
    Description: 
Feature request:
Allow users to specify a typehint for the accumulator type of CombineFn, either 
through a typehints decorator, or by using Python type annotations on the 
CombineFn methods, or through inheriting a CombineFn [generic 
type|https://docs.python.org/3/library/typing.html#user-defined-generic-types].

Benefits:
 * Allow the user to [specify a more efficient 
coder|https://beam.apache.org/documentation/programming-guide/#data-encoding-and-type-safety]
 for accumulators if one is available. Currently users are able to do this for 
the input and output elements, but not the accumulators, which [always uses the 
fallback 
coder|https://github.com/apache/beam/blob/d664592ee761d45b0273edb027a18c6ed9340349/sdks/python/apache_beam/transforms/core.py#L859-L860].
 * Allows typechecking of methods for CombineFn e.g. check that 
create_accumulator(), add_input() and merge_accumulators() returns 
accumulators. This provides better developer ergonomics as the CombineFnAPI is 
non-trivial.

  was:
Feature request:
Allow users to specify a typehint for the accumulator type of CombineFn, either 
through a typehints decorator, or by using Python type annotations on the 
CombineFn methods, or through inheriting a CombineFn [generic 
type|https://docs.python.org/3/library/typing.html#user-defined-generic-types].

Benefits:
 * Allow the user to [specify a more efficient 
coder|https://beam.apache.org/documentation/programming-guide/#data-encoding-and-type-safety]
 for accumulators if one is available. Currently users are able to do this for 
the input and output elements, but not the accumulators, which [always uses the 
fallback 
coder|https://github.com/apache/beam/blob/d664592ee761d45b0273edb027a18c6ed9340349/sdks/python/apache_beam/transforms/core.py#L859-L860].
 * Allows typechecking of methods for CombineFn e.g. check that 
create_accumulator(), add_input() and merge_accumulators() returns 
accumulators. This provides better developer ergonomics as the CombineFnAPI is 
non-trivial


> Typehint for Python CombineFn Accumulator
> -----------------------------------------
>
>                 Key: BEAM-8519
>                 URL: https://issues.apache.org/jira/browse/BEAM-8519
>             Project: Beam
>          Issue Type: New Feature
>          Components: sdk-py-core
>            Reporter: Yifan Mai
>            Priority: Minor
>
> Feature request:
> Allow users to specify a typehint for the accumulator type of CombineFn, 
> either through a typehints decorator, or by using Python type annotations on 
> the CombineFn methods, or through inheriting a CombineFn [generic 
> type|https://docs.python.org/3/library/typing.html#user-defined-generic-types].
> Benefits:
>  * Allow the user to [specify a more efficient 
> coder|https://beam.apache.org/documentation/programming-guide/#data-encoding-and-type-safety]
>  for accumulators if one is available. Currently users are able to do this 
> for the input and output elements, but not the accumulators, which [always 
> uses the fallback 
> coder|https://github.com/apache/beam/blob/d664592ee761d45b0273edb027a18c6ed9340349/sdks/python/apache_beam/transforms/core.py#L859-L860].
>  * Allows typechecking of methods for CombineFn e.g. check that 
> create_accumulator(), add_input() and merge_accumulators() returns 
> accumulators. This provides better developer ergonomics as the CombineFnAPI 
> is non-trivial.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to