Skip to main content

AllegroGraph Python API

PyPI - Python Version PyPI package Anaconda package

The AllegroGraph Python API offers convenient and efficient access to an AllegroGraph server from a Python-based application. This API provides methods for creating, querying and maintaining RDF data, and for managing the stored triples. The AllegroGraph Python API deliberately emulates the Eclipse RDF4J (formerly Aduna Sesame) API to make it easier to migrate from RDF4J to AllegroGraph. The AllegroGraph Python API has also been extended in ways that make it easier and more intuitive than the RDF4J API.

Requirements

Python versions >=3.11,<3.15 are supported. The installation method described here uses the pip package manager. On some systems this might require installing an additional package (e.g. python-pip on RHEL/CentOS systems). All third-party libraries used by the Python client will be downloaded automatically during installation.

Installation

Important: It is highly recommended to perform the install in a virtualenv environment.

The client can be installed from PyPI using the pip package manager:

pip install agraph-python

Alternatively, a distribution archive can be obtained from ftp://ftp.franz.com/pub/agraph/python-client and installed using pip:

pip install agraph-python-<VERSION>.tar.gz

Offline installation

If it is not possible to access PyPI from the target machine, the following steps should be taken:

  • In a compatible environment with unrestricted network access run:

    pip wheel agraph-python
    
  • This will generate a number of .whl files in the current directory. These files must be transferred to the target machine.

  • On the target machine use this command to install:

    pip install --no-index --find-links=<DIR> agraph-python
    

    where <DIR> is the directory containing the .whl files generated in the previous step.

Install by conda

Using conda to install agraph-python is also supported:

conda create -n myenv python=3.11
conda activate myenv
conda install -y -c conda-forge -c franzinc agraph-python

Testing

To validate the installation make sure that you have access to an AllegroGraph server and run the following Python script:

from franz.openrdf.connect import ag_connect
    with ag_connect('repo', host='HOST', port='PORT',
                    user='USER', password='PASS') as conn:
    print (conn.size())

Substitute appropriate values for the HOST/PORT/USER/PASS placeholders. If the script runs successfully a new repository named repo will be created.

Proxy setup

It is possible to configure the AllegroGraph Python client to use a proxy for all its connection to the server. This can be achieved by setting the AGRAPH_PROXY environment variable, as in the following example:

# Create a SOCKS proxy for tunneling to an internal network
ssh -fN -D 1080 user@gateway.example.com
# Configure agraph-python to use this proxy
export AGRAPH_PROXY=socks://localhost:1080

The format of the AGRAPH_PROXY value is TYPE://HOST:PORT, where TYPE can be either http, socks4, socks5 or socks (a synonym for socks5). Note that if a SOCKS proxy is used, DNS lookups will be performed by the proxy server.

Unit tests

The Python client includes a suite of unit tests that can be run after installation. The tests are executed using the pytest framework and also use a few utilities from nose, so these two packages have to be installed. We also need the pytest-mock plugin:

pip install -e ".[test]"

The tests require a running AllegroGraph server instance. The configuration of this server is passed to the tests through environment variables:

# Host and port where the server can be reached. These values are the
# default, it is only necessary to define the variables below if your
# setup is different
export AGRAPH_HOST=localhost
export AGRAPH_PORT=10035

# Tests will create repositories in this catalog.
# It must exist on the server. Use "/" for the root catalog.
export AGRAPH_CATALOG=tests

# Login credentials for the AG server.
# The user must have superuser privileges.
export AGRAPH_USER=test

# Use a prompt to read the password
read -s -r -p "Password for user ${AGRAPH_USER}: " AGRAPH_PASSWORD
export AGRAPH_PASSWORD

To run the tests, type:

pytest --pyargs franz.openrdf.tests.tests --pyargs franz.openrdf.tests.newtests

Metadata

Release files for agraph-python 105.4.0

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

Source distribution (sdist)

Source distribution for agraph-python 105.4.0
File Size Uploaded Provenance
agraph_python-105.4.0.tar.gz 203.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agraph-python 105.4.0
File Interpreter ABI Platform
agraph_python-105.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 443.8 kB

Release files / agraph_python-105.4.0.tar.gz

Download URL agraph_python-105.4.0.tar.gz
Size 203.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f5023a3a66bf7428314a5bc365a49b2c7b4336e593de6584cc84cb06a2ceba0e
BLAKE2b-256 checksum
How to use checksums
522de7b9a322e144b99e0cfb8fac5f9f57a8b4ced47b8a0e9c7609b7092119e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.11.16 HTTPX/0.28.1

Release files / agraph_python-105.4.0-py3-none-any.whl

Download URL agraph_python-105.4.0-py3-none-any.whl
Size 240.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d188fdd4502c986eeaae4947d13bf8094601abd56a3b5734c432a05c2a3a8e1
BLAKE2b-256 checksum
How to use checksums
582c953e4d3deaf03aac4ed2c31a918b4d8e3babbab19a254f040bd80ba77bc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.11.16 HTTPX/0.28.1

Security for agraph-python 105.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

105.4.0 This release

2 release files No provenance

6.1.4rc1

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