-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation on thread-safety and add API for pregel
- Loading branch information
Showing
13 changed files
with
269 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '3.10.1' | ||
VERSION = '3.11.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _pregel-page: | ||
|
||
Pregel | ||
------ | ||
|
||
**Python-arango** provides APIs for distributed iterative graph processing | ||
(Pregel). For more information, please refer to the ArangoDB manual | ||
`here <https://docs.arangodb.com/Manual/Graphs/Pregel/>`__. | ||
|
||
Here is an example showing how Pregel jobs can be started, fetched or cancelled: | ||
|
||
.. code-block:: python | ||
from arango import ArangoClient | ||
client = ArangoClient() | ||
db = client.db('my_database') | ||
db.create_graph('my_graph') | ||
# Create and start a new Pregel job | ||
job_id = db.create_pregel_job(algorithm='pagerank', graph='my_graph') | ||
# Get the details of a Pregel job by its ID | ||
job = db.pregel_job(job_id) | ||
print(job['aggregators']) | ||
print(job['edge_count']) | ||
print(job['gss']) | ||
print(job['received_count']) | ||
print(job['send_count']) | ||
print(job['state']) | ||
print(job['total_runtime']) | ||
print(job['vertex_count']) | ||
# Delete/cancel a Pregel job by its ID | ||
db.delete_pregel_job(job_id) | ||
Refer to class :class:`arango.database.Database` for more details on the methods | ||
for Pregel jobs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. _multithreading-page: | ||
|
||
Multithreading | ||
-------------- | ||
|
||
|
||
Notes on Eventlet | ||
================= | ||
|
||
**Python-arango** should be compatible with eventlet_ *for the most part*. | ||
By default, **python-arango** makes API calls to ArangoDB using the requests_ | ||
library which can be monkeypatched: | ||
|
||
.. code-block:: python | ||
import eventlet | ||
requests = eventlet.import_patched("requests") | ||
.. _requests: https://github.com/requests/requests | ||
.. _eventlet: http://eventlet.net | ||
|
||
Assuming the requests library is used and monkeypatched properly, all | ||
python-arango APIs except :ref:`Batch Execution <batch-page>` and | ||
:ref:`Async Execution <async-page>` should be thread-safe. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
|
||
import pytest | ||
|
||
from arango import ArangoClient | ||
from arango.exceptions import ( | ||
PregelJobCreateError, | ||
PregelJobGetError, | ||
PregelJobDeleteError | ||
) | ||
|
||
from .utils import ( | ||
generate_db_name, | ||
generate_col_name, | ||
generate_graph_name, | ||
) | ||
|
||
arango_client = ArangoClient() | ||
db_name = generate_db_name() | ||
db = arango_client.create_database(db_name) | ||
graph_name = generate_graph_name() | ||
graph = db.create_graph(graph_name) | ||
from_col_name = generate_col_name() | ||
to_col_name = generate_col_name() | ||
edge_col_name = generate_col_name() | ||
graph.create_vertex_collection(from_col_name) | ||
graph.create_vertex_collection(to_col_name) | ||
graph.create_edge_definition( | ||
edge_col_name, [from_col_name], [to_col_name] | ||
) | ||
|
||
|
||
def teardown_module(*_): | ||
arango_client.delete_database(db_name, ignore_missing=True) | ||
|
||
|
||
@pytest.mark.order1 | ||
def test_start_pregel_job(): | ||
# Test start_pregel_job with page rank algorithm (happy path) | ||
job_id = db.create_pregel_job('pagerank', graph_name) | ||
assert isinstance(job_id, int) | ||
|
||
# Test start_pregel_job with unsupported algorithm | ||
with pytest.raises(PregelJobCreateError): | ||
db.create_pregel_job('unsupported_algorithm', graph_name) | ||
|
||
|
||
@pytest.mark.order2 | ||
def test_get_pregel_job(): | ||
# Create a test Pregel job | ||
job_id = db.create_pregel_job('pagerank', graph_name) | ||
|
||
# Test pregel_job with existing job ID (happy path) | ||
job = db.pregel_job(job_id) | ||
assert isinstance(job['aggregators'], dict) | ||
assert isinstance(job['gss'], int) | ||
assert isinstance(job['received_count'], int) | ||
assert isinstance(job['send_count'], int) | ||
assert isinstance(job['total_runtime'], float) | ||
assert job['state'] == 'running' | ||
assert 'edge_count' in job | ||
assert 'vertex_count' in job | ||
|
||
# Test pregel_job with an invalid job ID | ||
with pytest.raises(PregelJobGetError): | ||
db.pregel_job(-1) | ||
|
||
|
||
@pytest.mark.order3 | ||
def test_delete_pregel_job(): | ||
# Create a test Pregel job | ||
job_id = db.create_pregel_job('pagerank', graph_name) | ||
|
||
# Get the newly created job | ||
job = db.pregel_job(job_id) | ||
assert job['state'] == 'running' | ||
|
||
# Test delete_pregel_job with existing job ID (happy path) | ||
assert db.delete_pregel_job(job_id) == True | ||
|
||
# The fetch for the same job should now fail | ||
with pytest.raises(PregelJobGetError): | ||
db.pregel_job(job_id) | ||
|
||
# Test delete_pregel_job with an invalid job ID | ||
with pytest.raises(PregelJobDeleteError): | ||
db.delete_pregel_job(-1) |