Madhukumar created HBASE-23644:
----------------------------------

             Summary: Thrift2 DemoClient.py
                 Key: HBASE-23644
                 URL: https://issues.apache.org/jira/browse/HBASE-23644
             Project: HBase
          Issue Type: Improvement
    Affects Versions: 2.2.2
            Reporter: Madhukumar
             Fix For: 2.2.4
         Attachments: DemoClient.py

*hbase-examples/py*

I tried to connect to hbase thrift2 server with python with given demo file 
DemoClient.py.  Issue is the DemoClient.py is not updated for python 3.X.  
Python 2.X support has ended. Even the github vesrion is not updated, happy to 
update it. 

I'm using python 3.8. {color:#ff0000}_Attached file for DemoClient.py for 
python 3.X._ I'm new to Jira and hbase. {color} __ 
 
 hbase.thrift file that was used to generate gen-py in 2.2.22 release examples 
does seem like this file 
hbase-src-2.2.2/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift.
 _I'm looking for hbase.thrift that was used to get gen-py in py examples. If 
you can point me to that, that will be great._

{color:#172b4d}If you generate gen-py using thrift compiler 0.13, this is error 
that I'm getting when running DemoClient.py, {color}

{color:#172b4d}Traceback (most recent call last):
 File "DemoClient.py", line 68, in <module>
 client.put(table, put)
 File 
"/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
 line 813, in put
 self.send_put(table, tput)
 File 
"/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
 line 821, in send_put
 args.write(self._oprot)
 File 
"/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
 line 4461, in write
 oprot.writeBinary(self.table)
 File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/protocol/TBinaryProtocol.py",
 line 131, in writeBinary
 self.trans.write(str)
 File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py",
 line 174, in write
 raise e
 File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py",
 line 170, in write
 self.__wbuf.write(buf)
 TypeError: a bytes-like object is required, not 'str'{color}

{color:#172b4d}Please note that I'm using 0.13 py client package for thrift. It 
does not work with thrift==0.9.3 as well.{color}

Out of the box gen-py that came with 2.2.2 source examples has the following 
issues working with thrift 0.13 py packages and it is also not code generated 
for python 3.0 but 2.0.
 * ttypes.py > self.__dict.__iteritems() does not work in python 3.0, so it 
need to be items 
 * xrange does not work in python 3.0 so all that need to be range 

 

thrift compiler 0.13 was available at this point from apache/thrift. It 
generates the files for python 2.0 it seems because of above two issues because 
hbase.thrift that is src (link given above), not sure what can be done about 
this. 

So, I have 0.13 python thrift package which works with python 3.0. 
DemoClient.py updated to 3.0 but issue is gen-py generation. I don't want to 
edit these generated py files, so if right hbase.thrift file that works with 
thrift 0.13.0 compiler, that will be great. Thanks.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to