Skip to main content

JanusGraph-Python extends Apache TinkerPop™s Gremlin-Python with support for JanusGraph-specific types.

Project description

JanusGraph-Python

JanusGraph-Python extends Apache TinkerPop™'s Gremlin-Python with support for JanusGraph-specific types.

Usage

To connect to JanusGraph Server, a DriverRemoteConnection instance needs to be created and configured with a message serializer that adds support for JanusGraph specific types.

This can be done like this for GraphSON 3:

from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from janusgraph_python.driver.serializer import JanusGraphSONSerializersV3d0

connection = DriverRemoteConnection(
	'ws://localhost:8182/gremlin', 'g',
	message_serializer=JanusGraphSONSerializersV3d0())

Note that the client should be disposed on shut down to release resources and to close open connections with connection.close(). The connection can then be used to configure a GraphTraversalSource:

from gremlin_python.process.anonymous_traversal import traversal

g = traversal().with_remote(connection)
# Reuse 'g' across the application

The GraphTraversalSource g can now be used to spawn Gremlin traversals:

hercules_age = g.V().has("demigod", "name", "hercules").values("age").next()
print(f"Hercules is {hercules_age} years old.")

Refer to the chapter Gremlin Query Language in the JanusGraph docs for an introduction to Gremlin and pointers to further resources. The main syntactical difference for Gremlin-Python is that it follows Python naming conventions, e.g., method names use snake_case instead of camelCase. Other difference is that when Python reserved words (e.g. "is") overlap with Gremlin steps or tokens, those gets underscore suffix (e.g. "is_").

Text Predicates

The Text class provides methods for full-text and string searches:

from janusgraph_python.process.traversal import Text

g.V().has("demigod", "name", Text.text_prefix("herc")).to_list()

The other text predicates can be used the same way.

Version Compatibility

The lowest supported JanusGraph version is 1.0.0. The following table shows the supported JanusGraph versions for each version of JanusGraph-Python:

JanusGraph-Python JanusGraph
1.0.z 1.0.z

While it should also be possible to use JanusGraph-Python with other versions of JanusGraph than mentioned here, compatibility is not tested and some functionality (like added Gremlin steps) will not work as it is not supported yet in case of an older JanusGraph version or was removed in a newer JanusGraph version.

Serialization Formats

JanusGraph-Python supports GraphSON 3 only. GraphBinary is not yet supported.

Not all of the JanusGraph-specific types are already supported by the formats:

Format RelationIdentifier Text predicates Geoshapes Geo predicates
GraphSON3 x x - -
GraphBinary - - - -

Community

JanusGraph-Python uses the same communication channels as JanusGraph in general. So, please refer to the Community section in JanusGraph's main repository for more information about these various channels.

Please use GitHub issues only to report bugs or request features.

Contributing

Please see CONTRIBUTING.md in JanusGraph's main repository for more information, including CLAs and best practices for working with GitHub.

License

JanusGraph-Python code is provided under the Apache 2.0 license and documentation is provided under the CC-BY-4.0 license. For details about this dual-license structure, please see LICENSE.txt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

janusgraphpython-1.0.0.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

janusgraphpython-1.0.0-py3-none-any.whl (40.4 kB view details)

Uploaded Python 3

File details

Details for the file janusgraphpython-1.0.0.tar.gz.

File metadata

  • Download URL: janusgraphpython-1.0.0.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for janusgraphpython-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3dc85a34321dc88cba2f9f3919dd1e2a94c7a8af6cc041d24483bc0fc9f2f515
MD5 e3c834e9300142aac8c80a9839c10003
BLAKE2b-256 9ec61946042b80b9214b60a2c212a21655a8006d1f73aed3f967964a6ed7a125

See more details on using hashes here.

File details

Details for the file janusgraphpython-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for janusgraphpython-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 390ac506e94912ae3cfa6f94ac30a42525d1243b4c276b9ea90e5edb142cfe15
MD5 647686a264e9a99927e0a97547dabbed
BLAKE2b-256 ba51862143a30ba561b2e409e9242987b64dedbc271e033444a8499abf8b696f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page