Skip to main content

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())

This can be done like this for GraphBinary:

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

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

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
1.1.z (1.0.z,) 1.1.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 as well as GraphBinary.

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

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

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.

Metadata

Release files for janusgraphpython 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for janusgraphpython 1.1.1
File Size Uploaded
janusgraphpython-1.1.1.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for janusgraphpython 1.1.1
File Interpreter ABI Platform
janusgraphpython-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 72.4 kB

Release files / janusgraphpython-1.1.1.tar.gz

Download URL janusgraphpython-1.1.1.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b0a4b82fb69cb30a101b7108a1a83c08c747d00eecbecb884af06b923e4ace2f
BLAKE2b-256 checksum
How to use checksums
fbfbc4d475a1ca2ee4439924de860b07dd45b08398bc859ff1e191e8d3238717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2025.

Transparency log

Release files / janusgraphpython-1.1.1-py3-none-any.whl

Download URL janusgraphpython-1.1.1-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96c87ce0e0f75be715df356d08cb5ae9452c48ec1c817005890ecf8dc8f59e67
BLAKE2b-256 checksum
How to use checksums
0550bf1820ad002004832ec5a00a21558cc3c89c04c286aee548d05e000eaa94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page