[
https://issues.apache.org/jira/browse/BEAM-7342?focusedWorklogId=251184&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-251184
]
ASF GitHub Bot logged work on BEAM-7342:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/May/19 17:52
Start Date: 30/May/19 17:52
Worklog Time Spent: 10m
Work Description: lukecwik commented on pull request #8607: [BEAM-7342]
Extend SyntheticPipeline map steps to be splittable.
URL: https://github.com/apache/beam/pull/8607#discussion_r289080074
##########
File path: sdks/python/apache_beam/testing/synthetic_pipeline.py
##########
@@ -116,6 +118,149 @@ def process(self, element):
yield element
+class NonLiquidShardingOffsetRangeTracker(OffsetRestrictionTracker):
+ """ A OffsetRangeTracker that doesn't allow splitting. """
+
+ def try_split(self, split_offset):
+ return # Don't split.
+
+ def checkpoint(self):
+ return # Don't split.
+
+
+class SyntheticSDFStepRestrictionProvider(RestrictionProvider):
+ """A `RestrictionProvider` for SyntheticSDFStep.
+
+ An initial_restriction and split that operate on num_records and ignore
+ source description (element). Splits into initial_splitting_num_bundles.
+ Returns size_estimate_override as restriction size, if set. Otherwise uses
+ element size.
+
+ If initial_splitting_uneven_chunks, produces uneven chunks.
+
+ """
+
+ def __init__(self, num_records, initial_splitting_num_bundles,
+ initial_splitting_uneven_chunks, disable_liquid_sharding,
+ size_estimate_override):
+ self._num_records = num_records
+ self._initial_splitting_num_bundles = initial_splitting_num_bundles
+ self._initial_splitting_uneven_chunks = initial_splitting_uneven_chunks
+ self._disable_liquid_sharding = disable_liquid_sharding
+ self._size_estimate_override = size_estimate_override
+
+ def initial_restriction(self, element):
+ return (0, self._num_records)
+
+ def create_tracker(self, restriction):
+ if self._disable_liquid_sharding:
+ return NonLiquidShardingOffsetRangeTracker(restriction[0],
+ restriction[1])
+ else:
+ # OffsetRange.new_tracker returns a RangeTracker - not
RestrictionTracker.
+ return OffsetRestrictionTracker(restriction[0], restriction[1])
+
+ def split_randomly(self, restriction):
+ ''' Randomly split the restriction into the right number of bundles.'''
+ elems = restriction[1] - restriction[0]
+ bundles = self._initial_splitting_num_bundles
+ randomNums = [np.random.randint(0, elems - 1) for _ in
+ range(0, bundles - 1)]
+ print randomNums
Review comment:
```suggestion
```
----------------------------------------------------------------
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: 251184)
Time Spent: 4h (was: 3h 50m)
> Extend SyntheticPipeline map steps to be able to be splittable (Beam Python
> SDK)
> --------------------------------------------------------------------------------
>
> Key: BEAM-7342
> URL: https://issues.apache.org/jira/browse/BEAM-7342
> Project: Beam
> Issue Type: New Feature
> Components: testing
> Environment: Beam Python
> Reporter: Lara Schmidt
> Assignee: Lara Schmidt
> Priority: Minor
> Original Estimate: 1m
> Time Spent: 4h
> Remaining Estimate: 0h
>
> Add the ability for map steps to be configured to be splittable.
> Possible configuration options:
> - uneven bundle sizes
> - possible incorrect sizing returned
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)