Skip to content

Commit

Permalink
Modify version and readme (#78)
Browse files Browse the repository at this point in the history
* modify version to 2.0.0rc1

* modify example

* modify changelog
  • Loading branch information
laura-ding committed Jan 6, 2021
1 parent 8d2959e commit ba7f2eb
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 25 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## v2.0.0-be(2020-11-30)
## v2.0.0rc1(2021-01-06)
Compatible with the v2.0.0-RC1 version of nebula-graph

- New features
- Support to scan vertexes and edges
- Support more data type function

## v2.0.0-1(2020-11-30)
Compatible with the v2.0.0-beta version of nebula-graph

- New features
Expand Down
79 changes: 58 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ Before you start, please read this section to choose the right branch for you. I
```text
|--nebula-python
|
|-- nebula2 // client code
| |-- fbthrift // the fbthrift lib code
| |-- common
| |-- data
| |-- graph
| |-- meta
| |-- net // the net code for graph client
| |-- storage
| |-- Config.py // the pool config
| |__ Exception.py // the define exception
|
|-- nebula2 // client code
| |-- fbthrift // the fbthrift lib code
| |-- common
| |-- data
| |-- graph
| |-- meta
| |-- net // the net code for graph client
| |-- storage
| |-- Config.py // the pool config
| |__ Exception.py // the define exception
|
|-- examples
| |-- MultiThreadExample.py // the multi thread example
| |__ SimpleExample.py // the simple example
|
|-- tests // the test code
|
|-- setup.py // used to install or package
| |-- GraphClientMultiThreadExample.py // the multi thread example
| |-- GraphClientSimpleExample.py // the simple example
| |__ ScanVertexEdgeExample.py
|
|__ README.md // the introduction of nebula2-python
|-- tests // the test code
|
|-- setup.py // used to install or package
|
|__ README.md // the introduction of nebula2-python
```

Expand Down Expand Up @@ -65,7 +66,7 @@ When your environment cannot access `pypi`, you need to install the following pa
pip install nebula2-python
```

## Quick example
## Quick example to use graph-cleint to connect graphd

```python
from nebula2.gclient.net import ConnectionPool
Expand All @@ -82,8 +83,11 @@ ok = connection_pool.init([('127.0.0.1', 3699)], config)
# get session from the pool
session = connection_pool.get_session('root', 'nebula')

# show hosts
result = session.execute('SHOW HOSTS')
# select space
session.execute('USE nba')

# show tags
result = session.execute('SHOW TAGS')
print(result)

# release session
Expand All @@ -93,9 +97,42 @@ session.release()
connection_pool.close()
```

## Quick example to use storage-cleint to scan vertex and edge

You should make sure the scan client can connect to the address of storage which see from `SHOW HOSTS`

```python
from nebula2.mclient import MetaCache
from nebula2.sclient.GraphStorageClient import GraphStorageClient

# the metad servers's address
meta_cache = MetaCache([('172.28.1.1', 45500),
('172.28.1.2', 45500),
('172.28.1.3', 45500)],
50000)
graph_storage_client = GraphStorageClient(meta_cache)

resp = graph_storage_client.scan_vertex(
space_name='ScanSpace',
tag_name='person')
while resp.has_next():
result = resp.next()
for vertex_data in result:
print(vertex_data)

resp = graph_storage_client.scan_edge(
space_name='ScanSpace',
edge_name='friend')
while resp.has_next():
result = resp.next()
for edge_data in result:
print(edge_data)
```

## How to choose nebula-python

| Nebula2-Python Version | NebulaGraph Version |
|---|---|
| 2.0.0.post1 | 2.0.0beta |
| 2.0.0rc1 | 2.0.0-RC1 |

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
config.max_connection_pool_size = 2
# init connection pool
connection_pool = ConnectionPool()
assert connection_pool.init([('127.0.0.1', 3700), ('127.0.0.1', 3699)], config)
assert connection_pool.init([('127.0.0.1', 3699)], config)

# get session from the pool
client = connection_pool.get_session('root', 'nebula')
Expand Down
8 changes: 8 additions & 0 deletions example/ScanVertexEdgeExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def prepare_data():
config.max_connection_pool_size = 1
# init connection pool
connection_pool = ConnectionPool()
# the graphd server's address
assert connection_pool.init([('172.28.3.1', 3699)], config)
client = connection_pool.get_session('root', 'nebula')
client.execute('CREATE SPACE IF NOT EXISTS ScanSpace('
Expand Down Expand Up @@ -121,8 +122,10 @@ def scan_person_edge(graph_storage_client):
"""

if __name__ == '__main__':
meta_cache = None
graph_storage_client = None
try:
# the metad servers's address
meta_cache = MetaCache([('172.28.1.1', 45500),
('172.28.1.2', 45500),
('172.28.1.3', 45500)],
Expand All @@ -138,3 +141,8 @@ def scan_person_edge(graph_storage_client):
if graph_storage_client is not None:
graph_storage_client.close()
exit(1)
finally:
if graph_storage_client is not None:
graph_storage_client.close()
if meta_cache is not None:
meta_cache.close()
7 changes: 6 additions & 1 deletion nebula2/mclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ def __init__(self, meta_addrs, timeout=2000, load_period=10, decode_type='utf-8'
# load meta data
self._load_all()

def __del__(self):
def close(self):
self._close = True
if self._meta_client is not None:
self._meta_client.close()

def __del__(self):
self.close()

def _load_all(self):
try:
Expand Down
3 changes: 3 additions & 0 deletions nebula2/sclient/GraphStorageClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def __init__(self, meta_cache, time_out=60000):
def get_conns(self):
return self._connections

def __del__(self):
self.close()

def close(self):
try:
for conn in self._connections:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='nebula2-python',
version='2.0.0-1',
version='2.0.0rc1',
license="Apache 2.0 + Common Clause 1.0",
author='vesoft-inc',
author_email='info@vesoft.com',
Expand Down

0 comments on commit ba7f2eb

Please sign in to comment.