Skip to content

Commit 8816c00

Browse files
committed
Update all metadata and documentation
1 parent 04441da commit 8816c00

15 files changed

+326
-296
lines changed

LICENSE.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
License
33
*******
44

5-
HappyBase itself is licensed under a `MIT License
6-
<http://www.opensource.org/licenses/MIT>`_. HappyBase contains code originating
7-
from HBase sources, licensed under the `Apache License
5+
AIOHappyBase itself is licensed under a `MIT License
6+
<http://www.opensource.org/licenses/MIT>`_. AIOHappyBase contains code originating from HBase sources, licensed under the `Apache License
87
<http://www.apache.org/licenses/>`_ (version 2.0). Both license texts are
98
included below.
109

1110

12-
HappyBase License
11+
AIOHappyBase License
1312
=================
1413

1514
(This is the `MIT License <http://www.opensource.org/licenses/MIT>`_.)
1615

17-
Copyright © 2012 Wouter Bolsterlee
16+
Copyright © 2012 Wouter Bolsterlee // Original HappyBase author
17+
Copyright © 2019 Roger Aiudi
1818

1919
Permission is hereby granted, free of charge, to any person obtaining a copy of
2020
this software and associated documentation files (the "Software"), to deal in

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include Makefile
22
include requirements.txt
3-
include happybase/*.thrift
3+
include aiohappybase/*.thrift
44
include *.rst
55
include doc/conf.py doc/*.rst

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ doc:
1010

1111
test:
1212
-find coverage/ -mindepth 1 -delete
13-
python $$(which nosetests) $${TESTS}
13+
coverage run -m unittest $${TESTS}
14+
coverage html
1415

1516
clean:
1617
find . -name '*.py[co]' -delete

NEWS.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
Version history
22
===============
33

4-
.. py:currentmodule:: happybase
4+
.. py:currentmodule:: aiohappybase
5+
6+
7+
AIOHappyBase 1.2.0
8+
------------------
9+
10+
Release date: 2019-11-??
11+
12+
First release of the async version of HappyBase!
13+
14+
The version number is the same because the API is almost identical (albeit async) except for a few updates:
15+
16+
- Only Python 3.6+ will be supported (I like f-strings and ordered dictionaries, sue me:P)
17+
- ``Connection`` and ``ConnectionPool`` objects can be used as context managers (async and regular).
18+
- ``Connection.create_table()`` now returns the table instance.
19+
- Support for the framed transport and compact protocol have been dropped until thriftpy2.contrib.aio supports them as well.
520

621

722
HappyBase 1.2.0

README.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
HappyBase
2-
=========
1+
AIOHappyBase
2+
============
33

4-
**HappyBase** is a developer-friendly Python_ library to interact with Apache
5-
HBase_.
4+
**AIOHappyBase** is a developer-friendly Python_ library to interact asynchronously with Apache
5+
HBase_. It is a fork of the original [HappyBase](https://github.com/wbolster/happybase) library aiming to deliver a very similar API.
66

7-
* `Documentation <https://happybase.readthedocs.io/>`_ (Read the Docs)
8-
* `Downloads <http://pypi.python.org/pypi/happybase/>`_ (PyPI)
9-
* `Source code <https://github.com/wbolster/happybase>`_ (Github)
7+
* `Documentation <https://happybase.readthedocs.io/>`_ (Docs) (TODO)
8+
* `Downloads <http://pypi.python.org/pypi/aiohappybase/>`_ (PyPI) (TODO)
9+
* `Source code <https://github.com/aiudirog/aiohappybase>`_ (Github)
1010

1111
.. _Python: http://python.org/
1212
.. _HBase: http://hbase.apache.org/

aiohappybase/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def _acquire_connection(self, timeout: Real = None) -> Connection:
9797
"""Acquire a connection from the pool."""
9898
try:
9999
return await aio.wait_for(self._queue.get(), timeout)
100-
except aio.futures.TimeoutError:
100+
except aio.TimeoutError:
101101
raise NoConnectionsAvailable("Timeout waiting for a connection")
102102

103103
async def _return_connection(self, connection: Connection) -> None:

doc/api.rst

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,56 @@
22
API reference
33
=============
44

5-
.. py:currentmodule:: happybase
5+
.. py:currentmodule:: aiohappybase
66
7-
This chapter contains detailed API documentation for HappyBase. It is suggested
8-
to read the :doc:`user guide <user>` first to get a general idea about how
9-
HappyBase works.
7+
This chapter contains detailed API documentation for AIOHappyBase. It is suggested to read the :doc:`user guide <user>` first to get a general idea about how AIOHappyBase works.
108

11-
The HappyBase API is organised as follows:
9+
The AIOHappyBase API is organised as follows:
1210

13-
:py:class:`~happybase.Connection`:
14-
The :py:class:`~happybase.Connection` class is the main entry point for
11+
:py:class:`~aiohappybase.Connection`:
12+
The :py:class:`~aiohappybase.Connection` class is the main entry point for
1513
application developers. It connects to the HBase Thrift server and provides
1614
methods for table management.
1715

18-
:py:class:`~happybase.Table`:
16+
:py:class:`~aiohappybase.Table`:
1917
The :py:class:`Table` class is the main class for interacting with data in
2018
tables. This class offers methods for data retrieval and data manipulation.
2119
Instances of this class can be obtained using the
2220
:py:meth:`Connection.table()` method.
2321

24-
:py:class:`~happybase.Batch`:
22+
:py:class:`~aiohappybase.Batch`:
2523
The :py:class:`Batch` class implements the batch API for data manipulation,
2624
and is available through the :py:meth:`Table.batch()` method.
2725

28-
:py:class:`~happybase.ConnectionPool`:
26+
:py:class:`~aiohappybase.ConnectionPool`:
2927
The :py:class:`ConnectionPool` class implements a thread-safe connection
3028
pool that allows an application to (re)use multiple connections.
3129

3230

3331
Connection
3432
==========
3533

36-
.. autoclass:: happybase.Connection
34+
.. autoclass:: aiohappybase.Connection
3735

3836

3937
Table
4038
=====
4139

42-
.. autoclass:: happybase.Table
40+
.. autoclass:: aiohappybase.Table
4341

4442

4543
Batch
4644
=====
4745

48-
.. autoclass:: happybase.Batch
46+
.. autoclass:: aiohappybase.Batch
4947

5048

5149
Connection pool
5250
===============
5351

54-
.. autoclass:: happybase.ConnectionPool
52+
.. autoclass:: aiohappybase.ConnectionPool
5553

56-
.. autoclass:: happybase.NoConnectionsAvailable
54+
.. autoclass:: aiohappybase.NoConnectionsAvailable
5755

5856

5957
.. vim: set spell spelllang=en:

doc/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
master_doc = 'index'
4141

4242
# General information about the project.
43-
project = u'HappyBase'
44-
copyright = u'2012'
43+
project = u'AIOHappyBase'
44+
copyright = u'2019'
4545

4646
# The version info for the project you're documenting, acts as replacement for
4747
# |version| and |release|, also used in various other places throughout the
@@ -50,7 +50,7 @@
5050
# The short X.Y version.
5151
version_file = os.path.join(
5252
os.path.dirname(__file__),
53-
'../happybase/_version.py')
53+
'../aiohappybase/_version.py')
5454
with open(version_file, 'r') as fp:
5555
exec(fp.read())
5656
version = __version__

doc/development.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Development
77
Getting the source
88
------------------
99

10-
The HappyBase source code repository is hosted on GitHub:
10+
The AIOHappyBase source code repository is hosted on GitHub:
1111

12-
https://github.com/wbolster/happybase
12+
https://github.com/aiudirog/aiohappybase
1313

1414
To grab a copy, use this::
1515

16-
$ git clone https://github.com/wbolster/happybase.git
16+
$ git clone https://github.com/aiudirog/aiohappybase.git
1717

1818

1919

@@ -22,35 +22,36 @@ Setting up a development environment
2222

2323
Setting up a development environment from a Git branch is easy::
2424

25-
$ cd /path/to/happybase/
26-
$ mkvirtualenv happybase
27-
(happybase)$ pip install -r test-requirements.txt
28-
(happybase)$ pip install -e .
25+
$ cd /path/to/aiohappybase/
26+
$ python -m venv venv
27+
$ source venv/bin/activate
28+
(venv) $ pip install -r test-requirements.txt
29+
(venv) $ pip install -e .
2930

3031

3132
Running the tests
3233
-----------------
3334

34-
The tests use the `nose` test suite. To execute the tests, run::
35+
The tests use the `asynctest` test suite. To execute the tests, run::
3536

36-
(happybase)$ make test
37+
(venv) $ make test
3738

3839
Test outputs are shown on the console. A test code coverage report is saved in
3940
`coverage/index.html`.
4041

4142
If the Thrift server is not running on localhost, you can specify these
4243
environment variables (both are optional) before running the tests::
4344

44-
(happybase)$ export HAPPYBASE_HOST=host.example.org
45-
(happybase)$ export HAPPYBASE_PORT=9091
45+
(venv) $ export AIOHAPPYBASE_HOST=host.example.org
46+
(venv) $ export AIOHAPPYBASE_PORT=9091
4647

4748
To test the HBase 0.90 compatibility mode, use this::
4849

49-
(happybase)$ export HAPPYBASE_COMPAT=0.90
50+
(venv) $ export AIOHAPPYBASE_COMPAT=0.90
5051

51-
To test the framed Thrift transport mode, use this::
52+
To test the framed Thrift transport mode (once it is supported), use this::
5253

53-
(happybase)$ export HAPPYBASE_TRANSPORT=framed
54+
(venv) $ export AIOHAPPYBASE_TRANSPORT=framed
5455

5556
Contributing
5657
------------

doc/faq.rst

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ Frequently asked questions
33
==========================
44

55

6-
I love HappyBase! Can I donate?
7-
===============================
6+
I love AIOHappyBase! Can I donate?
7+
==================================
8+
9+
While I am not accepting donations at this time, the original author is:
10+
11+
**From the original HappyBase author, Wouter Bolsterlee:**
812

913
Thanks, I'm glad to hear that you appreciate my work! If you feel like, please
1014
make a small donation_ to sponsor my (spare time!) work on HappyBase. Small
@@ -25,39 +29,55 @@ applications using Thrift directly need to deal with many imports, sockets,
2529
transports, protocols, clients, Thrift types and mutation objects. For instance,
2630
look at the code required to connect to HBase and store two values::
2731

28-
from thrift import Thrift
29-
from thrift.transport import TSocket, TTransport
30-
from thrift.protocol import TBinaryProtocol
32+
import asyncio as aio
33+
34+
from thriftpy2.contrib.aio.client import TAsyncClient
35+
from thriftpy2.contrib.aio.socket import TAsyncSocket
36+
from thriftpy2.contrib.aio.transport.buffered import TAsyncBufferedTransport
37+
from thriftpy2.contrib.aio.protocol.binary import TAsyncBinaryProtocol
38+
39+
from hbase import Hbase, Mutation
3140

32-
from hbase import ttypes
33-
from hbase.Hbase import Client, Mutation
41+
async def main():
3442

35-
sock = TSocket.TSocket('hostname', 9090)
36-
transport = TTransport.TBufferedTransport(sock)
37-
protocol = TBinaryProtocol.TBinaryProtocol(transport)
38-
client = Client(protocol)
39-
transport.open()
43+
sock = TAsyncSocket('hostname', 9090)
44+
transport = TAsyncBufferedTransport(sock)
45+
protocol = TAsyncBinaryProtocol(transport)
46+
client = TAsyncClient(Hbase, protocol)
47+
transport.open()
48+
49+
mutations = [
50+
Mutation(column=b'family:qual1', value=b'value1'),
51+
Mutation(column=b'family:qual2', value=b'value2'),
52+
]
53+
await client.mutateRow(b'table-name', b'row-key', mutations)
54+
55+
aio.run(main())
4056

41-
mutations = [Mutation(column='family:qual1', value='value1'),
42-
Mutation(column='family:qual2', value='value2')]
43-
client.mutateRow('table-name', 'row-key', mutations)
4457

4558
:pep:`20` taught us that simple is better than complex, and as you can see,
46-
Thrift is certainly complex. HappyBase hides all the Thrift cruft below a
59+
Thrift is certainly complex. AIOHappyBase hides all the Thrift cruft below a
4760
friendly API. The resulting application code will be cleaner, more productive
48-
to write, and more maintainable. With HappyBase, the example above can be
61+
to write, and more maintainable. With AIOHappyBase, the example above can be
4962
simplified to this::
5063

51-
import happybase
64+
import asyncio as aio
65+
66+
from aiohappybase import Connection
67+
68+
async def main():
69+
async with Connection('hostname') as conn:
70+
table = conn.table(b'table-name')
71+
await table.put(b'row-key', {
72+
b'family:qual1': b'value1',
73+
b'family:qual2': b'value2',
74+
})
5275

53-
connection = happybase.Connection('hostname')
54-
table = connection.table('table-name')
55-
table.put('row-key', {'family:qual1': 'value1',
56-
'family:qual2': 'value2'})
76+
aio.run(main())
5777

5878
If you're not convinced and still think the Thrift API is not that bad, please
5979
try to accomplish some other common tasks, e.g. retrieving rows and scanning
60-
over a part of a table, and compare that to the HappyBase equivalents. If
61-
you're still not convinced by then, we're sorry to inform you that HappyBase is
62-
not the project for you, and we wish you all of luck maintaining your code ‒ or
63-
is it just Thrift boilerplate?
80+
over a part of a table, and compare that to the AIOHappyBase equivalents. If
81+
you're still not convinced by then, we're sorry to inform you that AIOHappyBase
82+
is not the project for you, and we wish you all of luck maintaining your code
83+
‒ or is it just Thrift boilerplate?

0 commit comments

Comments
 (0)