[
https://issues.apache.org/jira/browse/BEAM-11052?focusedWorklogId=502759&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-502759
]
ASF GitHub Bot logged work on BEAM-11052:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Oct/20 16:10
Start Date: 20/Oct/20 16:10
Worklog Time Spent: 10m
Work Description: TheNeuralBit commented on a change in pull request
#13066:
URL: https://github.com/apache/beam/pull/13066#discussion_r508657178
##########
File path: sdks/python/apache_beam/dataframe/convert_test.py
##########
@@ -85,6 +85,94 @@ def test_convert(self):
assert_that(pc_3a, equal_to(list(3 * a)), label='Check3a')
assert_that(pc_ab, equal_to(list(a * b)), label='Checkab')
+ def test_convert_memoization(self):
+ with beam.Pipeline() as p:
+ a = pd.Series([1, 2, 3])
+ b = pd.Series([100, 200, 300])
+
+ pc_a = p | 'A' >> beam.Create([a])
+ pc_b = p | 'B' >> beam.Create([b])
+
+ df_a = convert.to_dataframe(pc_a, proxy=a[:0])
+ df_b = convert.to_dataframe(pc_b, proxy=b[:0])
+
+ df_2a = 2 * df_a
+ df_3a = 3 * df_a
+ df_ab = df_a * df_b
+
+ # Converting multiple results at a time can be more efficient.
+ pc_2a_, pc_ab_ = convert.to_pcollection(df_2a, df_ab)
+ # Converting the same expressions should yeild the same pcolls
+ pc_3a, pc_2a, pc_ab = convert.to_pcollection(df_3a, df_2a, df_ab)
+
+ self.assertEqual(id(pc_2a), id(pc_2a_))
+ self.assertEqual(id(pc_ab), id(pc_ab_))
+
+ assert_that(pc_2a, equal_to(list(2 * a)), label='Check2a')
+ assert_that(pc_3a, equal_to(list(3 * a)), label='Check3a')
+ assert_that(pc_ab, equal_to(list(a * b)), label='Checkab')
+
+ def test_convert_memoization_yield_pandas(self):
+ with beam.Pipeline() as p:
+ a = pd.Series([1, 2, 3])
+ b = pd.Series([100, 200, 300])
+
+ pc_a = p | 'A' >> beam.Create([a])
+ pc_b = p | 'B' >> beam.Create([b])
+
+ df_a = convert.to_dataframe(pc_a, proxy=a[:0])
+ df_b = convert.to_dataframe(pc_b, proxy=b[:0])
+
+ df_2a = 2 * df_a
+ df_3a = 3 * df_a
+ df_ab = df_a * df_b
+
+ # Converting multiple results at a time can be more efficient.
+ pc_2a_, pc_ab_ = convert.to_pcollection(df_2a, df_ab,
Review comment:
Done
##########
File path: sdks/python/apache_beam/dataframe/convert_test.py
##########
@@ -85,6 +85,94 @@ def test_convert(self):
assert_that(pc_3a, equal_to(list(3 * a)), label='Check3a')
assert_that(pc_ab, equal_to(list(a * b)), label='Checkab')
+ def test_convert_memoization(self):
+ with beam.Pipeline() as p:
+ a = pd.Series([1, 2, 3])
+ b = pd.Series([100, 200, 300])
+
+ pc_a = p | 'A' >> beam.Create([a])
+ pc_b = p | 'B' >> beam.Create([b])
+
+ df_a = convert.to_dataframe(pc_a, proxy=a[:0])
+ df_b = convert.to_dataframe(pc_b, proxy=b[:0])
+
+ df_2a = 2 * df_a
+ df_3a = 3 * df_a
+ df_ab = df_a * df_b
+
+ # Converting multiple results at a time can be more efficient.
+ pc_2a_, pc_ab_ = convert.to_pcollection(df_2a, df_ab)
+ # Converting the same expressions should yeild the same pcolls
+ pc_3a, pc_2a, pc_ab = convert.to_pcollection(df_3a, df_2a, df_ab)
+
+ self.assertEqual(id(pc_2a), id(pc_2a_))
Review comment:
thanks, done
##########
File path: sdks/python/apache_beam/dataframe/convert_test.py
##########
@@ -85,6 +85,94 @@ def test_convert(self):
assert_that(pc_3a, equal_to(list(3 * a)), label='Check3a')
assert_that(pc_ab, equal_to(list(a * b)), label='Checkab')
+ def test_convert_memoization(self):
Review comment:
Done
----------------------------------------------------------------
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: 502759)
Time Spent: 1.5h (was: 1h 20m)
> to_pcollection should memoize on DF expressions
> -----------------------------------------------
>
> Key: BEAM-11052
> URL: https://issues.apache.org/jira/browse/BEAM-11052
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core
> Reporter: Brian Hulette
> Assignee: Brian Hulette
> Priority: P2
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> We should always return the same PCollection when `to_pcollection` is called
> multiple times with the same input, this will allow for better integration
> with interactive notebooks.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)