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.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 kraph 4.1.1
File Size Uploaded
kraph-4.1.1.tar.gz 109.8 kB Details

Built distribution (wheel)

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

Total release size: 224.5 kB

Release files / kraph-4.1.1.tar.gz

Download URL kraph-4.1.1.tar.gz
Size 109.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4f49976381b7bccda43484e291000b590a44e7ca5258e73b78f7b66b9122b14
BLAKE2b-256 checksum
How to use checksums
fbfebae560f32db041cd75b9a998754b436b838ffa1d53f8c2625f03f635fb8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.1-py3-none-any.whl

Download URL kraph-4.1.1-py3-none-any.whl
Size 114.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c53080c666c30354ec265c768596ff3b100128f824572aff052d196e2c3a421
BLAKE2b-256 checksum
How to use checksums
24a0609be52e01277bcb43bde4e988d573861232d7f5fea3d72143137fb1cd10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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

This release

4.1.1 This release

2 release files

4.1.0

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