[
https://issues.apache.org/jira/browse/BEAM-10258?focusedWorklogId=458314&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-458314
]
ASF GitHub Bot logged work on BEAM-10258:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Jul/20 21:18
Start Date: 13/Jul/20 21:18
Worklog Time Spent: 10m
Work Description: saavannanavati commented on a change in pull request
#12009:
URL: https://github.com/apache/beam/pull/12009#discussion_r453938415
##########
File path: sdks/python/apache_beam/typehints/decorators.py
##########
@@ -378,6 +378,56 @@ def has_simple_output_type(self):
self.output_types and len(self.output_types[0]) == 1 and
not self.output_types[1])
+ def strip_pcoll(self):
+ return self.strip_pcoll_helper(self.input_types,
+ self._has_input_types,
+ {'input_types': None},
+ ['apache_beam.pvalue.PBegin'],
+ 'An input typehint to a PTransform must be'
+ ' a single (or nested) type wrapped by '
+ 'a PCollection or PBegin. ',
+ 'strip_pcoll_input()').\
+ strip_pcoll_helper(self.output_types,
+ self.has_simple_output_type,
+ {'output_types': None},
+ ['apache_beam.pvalue.PDone'],
+ 'An output typehint to a PTransform must be'
+ ' a single (or nested) type wrapped by '
+ 'a PCollection or PDone. ',
+ 'strip_pcoll_output()')
+
+ def strip_pcoll_helper(
+ self,
+ my_type, # type: any
+ has_my_type, # type: Callable[[], bool]
+ kwarg_dict, # type: Dict[str, any]
+ my_valid_classes, # type: List[str]
+ error_str, # type: str
+ source_str # type: str
+ ):
+ # type: (...) -> IOTypeHints
+
+ if not has_my_type() or len(my_type[0]) != 1:
+ return self
+
+ my_type = my_type[0][0]
+
+ if isinstance(my_type, typehints.AnyTypeConstraint):
+ return self
+
+ valid_classes = ['apache_beam.pvalue.PCollection'] + my_valid_classes
+
+ if not any(valid_class in str(my_type) for valid_class in valid_classes):
Review comment:
TBD: Try using `__origin__` instead for subscripted types and
non-subscripted types
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 458314)
Time Spent: 15h 20m (was: 15h 10m)
> Support type hint annotations on PTransform's expand()
> ------------------------------------------------------
>
> Key: BEAM-10258
> URL: https://issues.apache.org/jira/browse/BEAM-10258
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core
> Reporter: Saavan Nanavati
> Assignee: Saavan Nanavati
> Priority: P2
> Time Spent: 15h 20m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)