GraphAr Python SDK provides Python bindings for the GraphAr C++ library, allowing user to work with GraphAr formatted graph data in Python environments. It includes both a high-level API for data manipulation and a command-line interface for common operations.
- Python >= 3.7
- pip (latest version recommended)
- CMake >= 3.15 (for building from source)
- Apache Arrow >= 12.0 (for building from source)
Install the latest released version from PyPI:
pip install -U grapharClone the repository and install the Python package:
git clone https://github.com/apache/incubator-graphar.git
cd incubator-graphar
pip install ./pythonFor verbose output during installation:
pip install -v ./pythonThe easiest way to get started is by using our pre-configured Docker environment:
docker run -it ghcr.io/apache/graphar-devAfter installation, you can import the GraphAr Python SDK in your Python scripts:
import grapharLoading graph information:
import graphar
# Load graph info from a YAML file
graph_info = graphar.graph_info.GraphInfo.load("path/to/graph.yaml")
# Access vertex information
vertex_info = graph_info.get_vertex_info("person")
print(f"Vertex type: {vertex_info.get_type()}")
# Access edge information
edge_info = graph_info.get_edge_info("person", "knows", "person")
print(f"Edge type: {edge_info.get_edge_type()}")GraphAr Python SDK also provides a command-line interface for common operations such as checking metadata, showing graph information, and importing data.
For detailed information about the CLI functionality, please see CLI Documentation.
make install_docs
make docsThe Python SDK exposes the core GraphAr functionality through several modules:
graphar.graph_info: Main API for working with graph, vertex, and edge informationgraphar.high_level: High-level API for data reading and writing
Note
under development.
You can find various examples in the examples directory which demonstrate usage of the underlying C++ library. These concepts translate directly to the Python SDK.
To contribute to the Python SDK, please follow the guidelines in the main CONTRIBUTING.md file.
GraphAr is distributed under Apache License 2.0. Please note that third-party libraries may not have the same license as GraphAr.