robertwb commented on code in PR #30035:
URL: https://github.com/apache/beam/pull/30035#discussion_r1458173836
##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -665,6 +677,30 @@ def __init__(self, windowing):
def expand(self, pcoll):
return pcoll | self._window_transform
+ @staticmethod
+ def _parse_time_unit(value, name):
+ time_units = {
+ 'ms': 0.001, 's': 1, 'm': 60, 'h': 60 * 60, 'd': 60 * 60 * 12
+ }
+ value, suffix = re.match(r'^(.*?)([^\d]*)$', str(value)).groups()
+ # Default to seconds if time unit suffix is not defined
+ if not suffix:
+ suffix = 's'
+ if not value:
+ raise ValueError(
+ f"Invalid windowing {name} value "
+ f"'{suffix if not value else value}'. "
+ f"Must provide numeric value.")
+ if suffix not in time_units:
+ raise ValueError((
+ "Invalid windowing {} time unit '{}'. " +
+ "Valid time units are {}.").format(
+ name,
+ suffix,
+ ', '.join("'{}'".format(k) for k in time_units.keys())))
Review Comment:
OK, that's fine.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]