+1. For example, one might do something like
split_lines_result = (lines
|
beam.ParDo(SplitLinesToWordsFn().with_output_types(
beam.typehints.Generator[int],
SplitLinesToWordsFn.OUTPUT_TAG_SHORT_WORDS=beam.typehints.Generator[unicode],
SplitLinesToWordsFn.OUTPUT_TAG_CHARACTER_COUNT=beam.typehints.Generator[unicode],
)).with_outputs(
SplitLinesToWordsFn.OUTPUT_TAG_SHORT_WORDS,
SplitLinesToWordsFn.OUTPUT_TAG_CHARACTER_COUNT,
main='words')
)
We could consider letting these be related positionally too.
On Mon, Dec 11, 2017 at 4:50 PM, Ahmet Altay <[email protected]> wrote:
> Hi Norio,
>
> Thank you for your interest. If you would like to work on this I can assign
> the JIRA to you. I do not think this change in sufficient or correct. This
> reads as if SplitLinesToWordsFn returns a Tuple of things, however instead
> it produces three unrelated collections of different types.
>
> I think the work for fixing the issue should be:
> - Clarifying what the API needs to look like for typehints in case of
> multiple outputs.
> - Updating documentation for that (pydocs &
> https://beam.apache.org/documentation/sdks/python-type-safety/).
> - Adding examples. At that point we can choose to either update current
> examples or add new examples.
>
> Thank you,
> Ahmet
>
> On Mon, Dec 11, 2017 at 2:48 AM, Akagi Norio <[email protected]>
> wrote:
>>
>> Hi,
>>
>> I’m working on a task BEAM-3280 (Add typehints with TaggedOutput) and just
>> want to clarify before I send a PR.
>> https://issues.apache.org/jira/browse/BEAM-3280
>>
>> Is it sufficient to modify the code in
>> apache_beam.cookbook.multiple_output_pardo.py like below ?
>>
>> # with_outputs allows accessing the explicitly tagged outputs of a DoFn.
>> split_lines_result = (lines
>> |
>> beam.ParDo(SplitLinesToWordsFn().with_output_types(
>> beam.typehints.Tuple[
>> beam.typehints.Generator[unicode],
>> beam.typehints.Generator[unicode],
>> beam.typehints.Generator[int],
>> ],
>> )).with_outputs(
>>
>> SplitLinesToWordsFn.OUTPUT_TAG_SHORT_WORDS,
>>
>> SplitLinesToWordsFn.OUTPUT_TAG_CHARACTER_COUNT,
>> main='words')
>> )
>>
>> Or do you expect something different to add a typehint to multiple
>> outputs?
>>
>> Regards,
>> Norio Akagi
>
>