[
https://issues.apache.org/jira/browse/BEAM-3342?focusedWorklogId=462149&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-462149
]
ASF GitHub Bot logged work on BEAM-3342:
----------------------------------------
Author: ASF GitHub Bot
Created on: 22/Jul/20 17:02
Start Date: 22/Jul/20 17:02
Worklog Time Spent: 10m
Work Description: chamikaramj commented on a change in pull request
#11295:
URL: https://github.com/apache/beam/pull/11295#discussion_r458937989
##########
File path: sdks/python/apache_beam/io/gcp/bigtableio.py
##########
@@ -1,151 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""BigTable connector
-
-This module implements writing to BigTable tables.
Review comment:
Unfortunately we forgot to mark this as experimental. So we'll have to
leave the sink here and add the new source to "experimental/bigtableio.py" for
backwards compatibility. When we are confident about the performance of the
source we can move it her. For example, I think we need to add support for
dynamic work rebalancing similar to Java BigTable source (can be in a future
PR).
##########
File path:
sdks/python/apache_beam/io/gcp/experimental/bigtableio_read_it_test.py
##########
@@ -0,0 +1,169 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+""" Integration test for GC Bigtable connector [read]."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import argparse
+import logging
+import unittest
+
+from nose.plugins.attrib import attr
+
+import apache_beam as beam
+from apache_beam.io.gcp.experimental.bigtableio import ReadFromBigtable
+from apache_beam.metrics.metric import MetricsFilter
+from apache_beam.options.pipeline_options import PipelineOptions
+from apache_beam.options.pipeline_options import SetupOptions
+from apache_beam.runners.runner import PipelineState
+
+try:
+ from google.cloud.bigtable import Client
+except ImportError:
+ Client = None
+
+
[email protected](Client is None, 'GC Bigtable dependencies are not installed')
+class BigtableReadTest(unittest.TestCase):
+ """ Bigtable Read Connector Test
+
+ This tests the ReadFromBigtable connector class via reading rows from
+ a Bigtable table and comparing the `Rows Read` metrics with the row
+ count known a priori.
+ """
+ def setUp(self):
+ self.options = parse_commane_line_arguments()
+
+ logging.info('\nProject ID: %s', self.options['project'])
+ logging.info('\nInstance ID: %s', self.options['instance'])
+ logging.info('\nTable ID: %s', self.options['table'])
+
+ self._p_options = PipelineOptions(**self.options)
+ self._p_options.view_as(SetupOptions).save_main_session = True
+
+ logging.getLogger().setLevel(self.options['log_level'])
+
+ # [OPTIONAL] Uncomment to save logs into a file
+ # self._setup_log_file()
+
+ # [OPTIONAL] Uncomment this to allow logging the pipeline options
+ # for key, value in self.p_options.get_all_options().items():
+ # logging.info('Pipeline option {:32s} : {}'.format(key, value))
+
+ def _setup_log_file(self):
+ if self.options['log_directory']:
+ # logging.basicConfig(
+ # filename='{}{}.log'.format(
+ # options['log_directory'], options['table']
+ # ),
+ # filemode='w',
+ # level=logging.DEBUG
+ # )
+
+ # Forward all the logs to a file
+ fh = logging.FileHandler(
+ filename='{}test_log_{}_RUNNER={}.log'.format(
+ self.options['log_directory'],
+ self.options['table'][-15:],
+ self.options['runner']))
+ fh.setLevel(logging.DEBUG)
+ logging.getLogger().addHandler(fh)
+
+ @attr('IT')
+ def test_bigtable_read(self):
+ logging.info(
+ 'Reading table "%s" of %d rows...',
+ self.options['table'],
+ self.options['row_count'] or 0)
+
+ p = beam.Pipeline(options=self._p_options)
+ _ = (
+ p | 'Read Test' >> ReadFromBigtable(
+ project_id=self.options['project'],
+ instance_id=self.options['instance'],
+ table_id=self.options['table'],
+ filter_=self.options['filter']))
+ self.result = p.run()
+ self.result.wait_until_finish()
+ assert self.result.state == PipelineState.DONE
+
+ query_result = self.result.metrics().query(
+ MetricsFilter().with_name('Rows Read'))
+
+ if query_result['counters']:
+ read_counter = query_result['counters'][0]
+ final_count = read_counter.committed
+ assert final_count == self.options['row_count']
+ logging.info(
+ '%d out of %d rows were read successfully.',
+ final_count,
+ self.options['row_count'])
+
+ logging.info('DONE!')
+
+
+def parse_commane_line_arguments():
+ parser = argparse.ArgumentParser()
+
Review comment:
You do not need to set these up manually. Please see the way our other
integration tests are setup. You can either configure a new Jenkins test suite
or add integration tests to existing Python post-commit tests. Latter might be
easier.
----------------------------------------------------------------
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: 462149)
Time Spent: 49.5h (was: 49h 20m)
> Create a Cloud Bigtable IO connector for Python
> -----------------------------------------------
>
> Key: BEAM-3342
> URL: https://issues.apache.org/jira/browse/BEAM-3342
> Project: Beam
> Issue Type: Bug
> Components: sdk-py-core
> Reporter: Solomon Duskis
> Priority: P2
> Time Spent: 49.5h
> Remaining Estimate: 0h
>
> I would like to create a Cloud Bigtable python connector.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)