Skip to main content

kraph

PyPI version PyPI pyversions

The python client for kraph, the Arkitekt knowledge graph service built around Apache AGE: recording claims about entities, events, measurements and metrics, backed by the structures (images, tables, …) that are evidence for them, and drawing them into graphs.

Installation

pip install kraph

With arkitekt, pip install "arkitekt[rekuest,kraph]" brings it in.

Concepts

  • Claims — an entity exists, a structure measures it, two things are related — are recorded under a term, a word your organization owns, never under a graph. Retracting a claim records a position rather than deleting anything.
  • Graphs are views. A graph declares categories (entity, relation, measurement, event, …) that say what its words mean, and draws the claims made under those words.

Usage

Every kraph operation is a method of the Kraph client, in a blocking and an a-prefixed async flavour (kraph.create_graph(...), await kraph.acreate_graph(...)). What a call returns remembers the client, so follow-ups from a result go through the same client.

In an arkitekt app

Add the service to your app and ask for kraph: Kraph; the client is injected by annotation. Graphs, categories, structures, metrics, terms and more travel between actions by id (@kraph/graph, @kraph/entitycategory, @kraph/structure, @kraph/term, …), so an action can take and return them directly:

from arkitekt import App, run
from kraph import Kraph, kraph_service

app = App("neuron-claims", "0.1.0", services=[kraph_service])


@app.action
def claim_neuron(kraph: Kraph) -> str:
    """Claim Neuron

    Records that a neuron exists.
    """
    asserted = kraph.assert_entity_exists(
        term="Neuron", supporting_evidence=[], derived_from=[], same_as=[]
    )
    return asserted.instance.id


if __name__ == "__main__":
    run(app)

From a script

from arkitekt import easy
from kraph import kraph_service

with easy("my-script", kraph_service) as kraph:
    graph = kraph.create_graph(name="Neurons", backfill=False)
    kraph.create_entity_category(
        key="Neuron",
        ontology_references=[],
        property_definitions=[],
        graph=graph.id,
        backfill=True,
    )

    asserted = kraph.assert_entity_exists(
        term="Neuron", supporting_evidence=[], derived_from=[], same_as=[]
    )
    print(asserted.is_drawn)  # True: the graph declares "Neuron", so it draws the claim

Testing

uv run pytest -m "not integration"   # no server needed
uv run pytest -m integration          # a real kraph via dokker

See RELEASING.md for how versions are cut.

Metadata

Release files for kraph 4.1.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 kraph 4.1.0
File Size Uploaded
kraph-4.1.0.tar.gz 109.8 kB Details

Built distribution (wheel)

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

Total release size: 224.5 kB

Release files / kraph-4.1.0.tar.gz

Download URL kraph-4.1.0.tar.gz
Size 109.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6bed4ec02f6927a62e1f9e3ee01957459f63aec7a5787849638f0177881f53db
BLAKE2b-256 checksum
How to use checksums
c50766db655d7c22695ac07a3eec88fbcbbeeb462d1779651e5973060bf9bfd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kraph-4.1.0-py3-none-any.whl

Download URL kraph-4.1.0-py3-none-any.whl
Size 114.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
910a865a71d4aab0c399265d35d6b8d9a0f5bfbf5c53491490720957cd279f16
BLAKE2b-256 checksum
How to use checksums
a4a237a4fd9e9ae67d711009ca68b2fdae2e98fda64ff5a78390c7729ed9f49d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

4.1.1

2 release files

This release

4.1.0 This release

2 release files

4.0.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.99

2 release files

0.1.98

2 release files

0.1.97

2 release files

0.1.96

2 release files

0.1.95

2 release files

0.1.94

2 release files

0.1.93

2 release files

0.1.92

2 release files

0.1.91

2 release files

0.1.90

2 release files

0.1.89

2 release files

0.1.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